source: XIOS/dev/dev_olga/src/node/field.cpp @ 1009

Last change on this file since 1009 was 1009, checked in by oabramkina, 7 years ago

First working version with compression by secondary servers.

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:executable set to *
File size: 44.3 KB
Line 
1#include "field.hpp"
2
3#include "attribute_template.hpp"
4#include "object_template.hpp"
5#include "group_template.hpp"
6
7#include "node_type.hpp"
8#include "calendar_util.hpp"
9#include "message.hpp"
10#include "xios_spl.hpp"
11#include "type.hpp"
12#include "timer.hpp"
13#include "context_client.hpp"
14#include "context_server.hpp"
15#include <set>
16#include "garbage_collector.hpp"
17#include "source_filter.hpp"
18#include "store_filter.hpp"
19#include "file_writer_filter.hpp"
20#include "pass_through_filter.hpp"
21#include "filter_expr_node.hpp"
22#include "lex_parser.hpp"
23#include "temporal_filter.hpp"
24#include "spatial_transform_filter.hpp"
25
26namespace xios{
27
28   /// ////////////////////// Définitions ////////////////////// ///
29
30   CField::CField(void)
31      : CObjectTemplate<CField>(), CFieldAttributes()
32      , grid(), file()
33      , written(false)
34      , nstep(0), nstepMax(0)
35      , hasOutputFile(false)
36      , domAxisScalarIds_(vector<StdString>(3,"")), areAllReferenceSolved(false), isReferenceSolved(false)
37      , useCompressedOutput(false)
38      , isReadDataRequestPending(false)
39   { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); }
40
41   CField::CField(const StdString& id)
42      : CObjectTemplate<CField>(id), CFieldAttributes()
43      , grid(), file()
44      , written(false)
45      , nstep(0), nstepMax(0)
46      , hasOutputFile(false)
47      , domAxisScalarIds_(vector<StdString>(3,"")), areAllReferenceSolved(false), isReferenceSolved(false)
48      , useCompressedOutput(false)
49      , isReadDataRequestPending(false)
50   { setVirtualVariableGroup(CVariableGroup::create(getId() + "_virtual_variable_group")); }
51
52   CField::~CField(void)
53   {}
54
55  //----------------------------------------------------------------
56
57   void CField::setVirtualVariableGroup(CVariableGroup* newVVariableGroup)
58   {
59      this->vVariableGroup = newVVariableGroup;
60   }
61
62   CVariableGroup* CField::getVirtualVariableGroup(void) const
63   {
64      return this->vVariableGroup;
65   }
66
67   std::vector<CVariable*> CField::getAllVariables(void) const
68   {
69      return this->vVariableGroup->getAllChildren();
70   }
71
72   void CField::solveDescInheritance(bool apply, const CAttributeMap* const parent)
73   {
74      SuperClassAttribute::setAttributes(parent, apply);
75      this->getVirtualVariableGroup()->solveDescInheritance(apply, NULL);
76   }
77
78  //----------------------------------------------------------------
79
80  bool CField::dispatchEvent(CEventServer& event)
81  {
82    if (SuperClass::dispatchEvent(event)) return true;
83    else
84    {
85      switch(event.type)
86      {
87        case EVENT_ID_UPDATE_DATA :
88          recvUpdateData(event);
89          return true;
90          break;
91
92        case EVENT_ID_READ_DATA :
93          recvReadDataRequest(event);
94          return true;
95          break;
96
97        case EVENT_ID_READ_DATA_READY :
98          recvReadDataReady(event);
99          return true;
100          break;
101
102        case EVENT_ID_ADD_VARIABLE :
103          recvAddVariable(event);
104          return true;
105          break;
106
107        case EVENT_ID_ADD_VARIABLE_GROUP :
108          recvAddVariableGroup(event);
109          return true;
110          break;
111
112        default :
113          ERROR("bool CField::dispatchEvent(CEventServer& event)", << "Unknown Event");
114          return false;
115      }
116    }
117  }
118
119  void CField::sendUpdateData(const CArray<double,1>& data)
120  {
121    CTimer::get("XIOS Send Data").resume();
122
123    CContext* context = CContext::getCurrent();
124//    CContextClient* client = context->client;
125    int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1;
126    for (int i = 0; i < nbSrvPools; ++i)
127    {
128      CContextClient* client = (!context->hasServer) ? context->client : context->clientPrimServer[i];
129
130      CEventClient event(getType(), EVENT_ID_UPDATE_DATA);
131
132      map<int, CArray<int,1> >::iterator it;
133      list<CMessage> list_msg;
134      list<CArray<double,1> > list_data;
135
136      if (!grid->doGridHaveDataDistributed())
137      {
138         if (client->isServerLeader())
139         {
140            for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++)
141            {
142              int rank = it->first;
143              CArray<int,1>& index = it->second;
144
145              list_msg.push_back(CMessage());
146              list_data.push_back(CArray<double,1>(index.numElements()));
147
148              CArray<double,1>& data_tmp = list_data.back();
149              for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n));
150
151              list_msg.back() << getId() << data_tmp;
152              event.push(rank, 1, list_msg.back());
153            }
154            client->sendEvent(event);
155         }
156         else client->sendEvent(event);
157      }
158      else
159      {
160        for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++)
161        {
162          int rank = it->first;
163          CArray<int,1>& index = it->second;
164
165          list_msg.push_back(CMessage());
166          list_data.push_back(CArray<double,1>(index.numElements()));
167
168          CArray<double,1>& data_tmp = list_data.back();
169          for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n));
170
171          list_msg.back() << getId() << data_tmp;
172          event.push(rank, grid->nbSenders[rank], list_msg.back());
173        }
174        client->sendEvent(event);
175      }
176    }
177
178    CTimer::get("XIOS Send Data").suspend();
179  }
180
181  void CField::sendUpdateData(const CArray<double,1>& data, const int srvPool)
182  {
183    CTimer::get("XIOS Send Data").resume();
184
185    CContext* context = CContext::getCurrent();
186    CContextClient* client = context->clientPrimServer[srvPool];
187
188    CEventClient event(getType(), EVENT_ID_UPDATE_DATA);
189
190    map<int, CArray<int,1> >::iterator it;
191    list<CMessage> list_msg;
192    list<CArray<double,1> > list_data;
193
194    if (!grid->doGridHaveDataDistributed())
195    {
196       if (client->isServerLeader())
197       {
198          for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++)
199          {
200            int rank = it->first;
201            CArray<int,1>& index = it->second;
202
203            list_msg.push_back(CMessage());
204            list_data.push_back(CArray<double,1>(index.numElements()));
205
206            CArray<double,1>& data_tmp = list_data.back();
207            for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n));
208
209            list_msg.back() << getId() << data_tmp;
210            event.push(rank, 1, list_msg.back());
211          }
212          client->sendEvent(event);
213       }
214       else client->sendEvent(event);
215    }
216    else
217    {
218      for (it = grid->storeIndex_toSrv.begin(); it != grid->storeIndex_toSrv.end(); it++)
219      {
220        int rank = it->first;
221        CArray<int,1>& index = it->second;
222
223        list_msg.push_back(CMessage());
224        list_data.push_back(CArray<double,1>(index.numElements()));
225
226        CArray<double,1>& data_tmp = list_data.back();
227        for (int n = 0; n < data_tmp.numElements(); n++) data_tmp(n) = data(index(n));
228
229        list_msg.back() << getId() << data_tmp;
230        event.push(rank, grid->nbSenders[rank], list_msg.back());
231      }
232      client->sendEvent(event);
233    }
234    CTimer::get("XIOS Send Data").suspend();
235  }
236
237  void CField::recvUpdateData(CEventServer& event)
238  {
239    vector<int> ranks;
240    vector<CBufferIn*> buffers;
241
242    list<CEventServer::SSubEvent>::iterator it;
243    string fieldId;
244
245    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
246    {
247      int rank = it->rank;
248      CBufferIn* buffer = it->buffer;
249      *buffer >> fieldId;
250      ranks.push_back(rank);
251      buffers.push_back(buffer);
252    }
253    get(fieldId)->recvUpdateData(ranks,buffers);
254  }
255
256  void  CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers)
257  {
258    CContext* context = CContext::getCurrent();
259
260    if (data_srv.empty())
261    {
262      for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it)
263      {
264        int rank = it->first;
265        data_srv.insert(std::make_pair(rank, CArray<double,1>(it->second.numElements())));
266        foperation_srv.insert(pair<int,boost::shared_ptr<func::CFunctor> >(rank,boost::shared_ptr<func::CFunctor>(new func::CInstant(data_srv[rank]))));
267      }
268    }
269
270    const CDate& currDate = context->getCalendar()->getCurrentDate();
271    const CDate opeDate      = last_operation_srv +freq_op + freq_operation_srv - freq_op;
272    const CDate writeDate    = last_Write_srv     + freq_write_srv;
273
274    if (opeDate <= currDate)
275    {
276      for (int n = 0; n < ranks.size(); n++)
277      {
278        CArray<double,1> data_tmp;
279        *buffers[n] >> data_tmp;
280        (*foperation_srv[ranks[n]])(data_tmp);
281      }
282      last_operation_srv = currDate;
283    }
284
285    if (writeDate < (currDate + freq_operation_srv))
286    {
287      for (int n = 0; n < ranks.size(); n++)
288      {
289        this->foperation_srv[ranks[n]]->final();
290      }
291
292      last_Write_srv = writeDate;
293    }
294
295    if (context->hasClient && context->hasServer)
296    {
297      size_t writtenSize;
298//      if (field->getUseCompressedOutput())
299//        writtenSize = grid->getNumberWrittenIndexes();
300//      else
301        writtenSize = grid->getWrittenDataSize();
302
303      CArray<double,1> fieldData(writtenSize);
304//      if (!field->default_value.isEmpty()) fieldData = field->default_value;
305
306//      if (field->getUseCompressedOutput())
307//        field->outputCompressedField(fieldData);
308//      else
309        this->outputField(fieldData);
310//        sendUpdateData(fieldData);
311        // Redirecting data to the correct secondary server
312        int fileIdx = std::find(context->enabledFiles.begin(), context->enabledFiles.end(), this->file) - context->enabledFiles.begin();
313        int srvId = fileIdx % context->clientPrimServer.size();
314        sendUpdateData(fieldData, srvId);
315    }
316    if (!context->hasClient && context->hasServer)
317    {
318//      size_t writtenSize;
319//      if (this->getUseCompressedOutput())
320//        writtenSize = grid->getNumberWrittenIndexes();
321//      else
322//        writtenSize = grid->getWrittenDataSize();
323//
324//      CArray<double,1> fieldData(writtenSize);
325
326//      if (this->getUseCompressedOutput())
327//        this->outputCompressedField(fieldData);
328//      else
329//        this->outputField(fieldData);
330      writeField();
331    }
332
333    lastlast_Write_srv = last_Write_srv;
334
335  }
336
337  void CField::writeField(void)
338  {
339    if (!getRelFile()->allDomainEmpty)
340    {
341      if (grid->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file)
342      {
343        getRelFile()->checkFile();
344        this->incrementNStep();
345        getRelFile()->getDataOutput()->writeFieldData(CField::get(this));
346      }
347    }
348  }
349
350  void CField::sendReadDataRequest(void)
351  {
352    CContext* context = CContext::getCurrent();
353    CContextClient* client = context->client;
354
355    lastDataRequestedFromServer = context->getCalendar()->getCurrentDate();
356    isReadDataRequestPending = true;
357
358    CEventClient event(getType(), EVENT_ID_READ_DATA);
359    if (client->isServerLeader())
360    {
361      CMessage msg;
362      msg << getId();
363      const std::list<int>& ranks = client->getRanksServerLeader();
364      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
365        event.push(*itRank, 1, msg);
366      client->sendEvent(event);
367    }
368    else client->sendEvent(event);
369  }
370
371  /*!
372  Send request new data read from file if need be, that is the current data is out-of-date.
373  \return true if and only if some data was requested
374  */
375  bool CField::sendReadDataRequestIfNeeded(void)
376  {
377    const CDate& currentDate = CContext::getCurrent()->getCalendar()->getCurrentDate();
378
379    bool requestData = (currentDate >= lastDataRequestedFromServer + file->output_freq.getValue());
380
381    if (requestData)
382    {
383      cout<<"currentDate : "<<currentDate<<endl ;
384      cout<<"lastDataRequestedFromServer : "<<lastDataRequestedFromServer<<endl ;
385      cout<<"file->output_freq.getValue() : "<<file->output_freq.getValue()<<endl ;
386      cout<<"lastDataRequestedFromServer + file->output_freq.getValue() : "<<lastDataRequestedFromServer + file->output_freq.getValue()<<endl ;
387
388      sendReadDataRequest();
389    }
390
391    return requestData;
392  }
393
394  void CField::recvReadDataRequest(CEventServer& event)
395  {
396    CBufferIn* buffer = event.subEvents.begin()->buffer;
397    StdString fieldId;
398    *buffer >> fieldId;
399    get(fieldId)->recvReadDataRequest();
400  }
401
402  void CField::recvReadDataRequest(void)
403  {
404    CContext* context = CContext::getCurrent();
405    CContextClient* client = context->client;
406
407    CEventClient event(getType(), EVENT_ID_READ_DATA_READY);
408    std::list<CMessage> msgs;
409
410    bool hasData = readField();
411
412    map<int, CArray<double,1> >::iterator it;
413    for (it = data_srv.begin(); it != data_srv.end(); it++)
414    {
415      msgs.push_back(CMessage());
416      CMessage& msg = msgs.back();
417      msg << getId();
418      if (hasData)
419        msg << getNStep() - 1 << it->second;
420      else
421        msg << int(-1);
422      event.push(it->first, grid->nbSenders[it->first], msg);
423    }
424    client->sendEvent(event);
425  }
426
427  bool CField::readField(void)
428  {
429    if (!getRelFile()->allDomainEmpty)
430    {
431      if (grid->doGridHaveDataToWrite() || getRelFile()->type == CFile::type_attr::one_file)
432      {
433        if (data_srv.empty())
434        {
435          for (map<int, CArray<size_t, 1> >::iterator it = grid->outIndexFromClient.begin(); it != grid->outIndexFromClient.end(); ++it)
436            data_srv.insert(std::make_pair(it->first, CArray<double,1>(it->second.numElements())));
437        }
438
439        getRelFile()->checkFile();
440        if (!nstepMax)
441        {
442          nstepMax = getRelFile()->getDataInput()->getFieldNbRecords(CField::get(this));
443        }
444
445        this->incrementNStep();
446
447
448
449        if (getNStep() > nstepMax && (getRelFile()->cyclic.isEmpty() || !getRelFile()->cyclic) )
450          return false;
451
452        getRelFile()->getDataInput()->readFieldData(CField::get(this));
453      }
454    }
455
456    return true;
457  }
458
459  void CField::recvReadDataReady(CEventServer& event)
460  {
461    string fieldId;
462    vector<int> ranks;
463    vector<CBufferIn*> buffers;
464
465    list<CEventServer::SSubEvent>::iterator it;
466    for (it = event.subEvents.begin(); it != event.subEvents.end(); ++it)
467    {
468      ranks.push_back(it->rank);
469      CBufferIn* buffer = it->buffer;
470      *buffer >> fieldId;
471      buffers.push_back(buffer);
472    }
473    get(fieldId)->recvReadDataReady(ranks, buffers);
474  }
475
476  void CField::recvReadDataReady(vector<int> ranks, vector<CBufferIn*> buffers)
477  {
478    CContext* context = CContext::getCurrent();
479    int record;
480    std::map<int, CArray<double,1> > data;
481
482    bool isEOF = false;
483
484    for (int i = 0; i < ranks.size(); i++)
485    {
486      int rank = ranks[i];
487      *buffers[i] >> record;
488      isEOF = (record == int(-1));
489
490      if (!isEOF)
491        *buffers[i] >> data[rank];
492      else
493        break;
494    }
495
496    if (isEOF)
497      serverSourceFilter->signalEndOfStream(lastDataRequestedFromServer);
498    else
499      serverSourceFilter->streamDataFromServer(lastDataRequestedFromServer, data);
500
501    isReadDataRequestPending = false;
502  }
503
504   //----------------------------------------------------------------
505
506   void CField::setRelFile(CFile* _file)
507   {
508      this->file = _file;
509      hasOutputFile = true;
510   }
511
512   //----------------------------------------------------------------
513
514   StdString CField::GetName(void)    { return StdString("field"); }
515   StdString CField::GetDefName(void) { return CField::GetName(); }
516   ENodeType CField::GetType(void)    { return eField; }
517
518   //----------------------------------------------------------------
519
520   CGrid* CField::getRelGrid(void) const
521   {
522      return this->grid;
523   }
524
525   //----------------------------------------------------------------
526
527   CFile* CField::getRelFile(void) const
528   {
529      return this->file;
530   }
531
532   int CField::getNStep(void) const
533   {
534      return this->nstep;
535   }
536
537   func::CFunctor::ETimeType CField::getOperationTimeType() const
538   {
539     return operationTimeType;
540   }
541
542   //----------------------------------------------------------------
543
544   void CField::incrementNStep(void)
545   {
546      this->nstep++;
547   }
548
549   void CField::resetNStep(int nstep /*= 0*/)
550   {
551      this->nstep = nstep;
552   }
553
554   void CField::resetNStepMax(void)
555   {
556      this->nstepMax = 0;
557   }
558
559   //----------------------------------------------------------------
560
561   bool CField::isActive(void) const
562   {
563      return (instantDataFilter != NULL);
564   }
565
566   //----------------------------------------------------------------
567
568   bool CField::wasWritten() const
569   {
570     return written;
571   }
572
573   void CField::setWritten()
574   {
575     written = true;
576   }
577
578   //----------------------------------------------------------------
579
580   bool CField::getUseCompressedOutput() const
581   {
582     return useCompressedOutput;
583   }
584
585   void CField::setUseCompressedOutput()
586   {
587     useCompressedOutput = true;
588   }
589
590   //----------------------------------------------------------------
591
592   boost::shared_ptr<COutputPin> CField::getInstantDataFilter()
593   {
594     return instantDataFilter;
595   }
596
597   //----------------------------------------------------------------
598
599   void CField::solveOnlyReferenceEnabledField(bool doSending2Server)
600   {
601     CContext* context = CContext::getCurrent();
602     if (!isReferenceSolved)
603     {
604        isReferenceSolved = true;
605
606        if (context->hasClient && !context->hasServer)
607//        if (context->hasClient)
608        {
609          solveRefInheritance(true);
610          if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(false);
611        }
612//        else if (context->hasServer)
613        if (context->hasServer)
614          solveServerOperation();
615
616        solveGridReference();
617
618        if (context->hasClient && !context->hasServer)
619//       if (context->hasClient)
620       {
621         solveGenerateGrid();
622         buildGridTransformationGraph();
623       }
624     }
625   }
626
627   /*!
628     Build up graph of grids which plays role of destination and source in grid transformation
629     This function should be called before \func solveGridReference()
630   */
631   void CField::buildGridTransformationGraph()
632   {
633     CContext* context = CContext::getCurrent();
634     if (context->hasClient && !context->hasServer)
635//     if (context->hasClient)
636     {
637       if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid)
638       {
639         grid->addTransGridSource(getDirectFieldReference()->grid);
640       }
641     }
642   }
643
644   /*!
645     Generate a new grid destination if there are more than one grid source pointing to a same grid destination
646   */
647   void CField::generateNewTransformationGridDest()
648   {
649     CContext* context = CContext::getCurrent();
650     if (context->hasClient && !context->hasServer)
651//     if (context->hasClient)
652     {
653       std::map<CGrid*,std::pair<bool,StdString> >& gridSrcMap = grid->getTransGridSource();
654       if (1 < gridSrcMap.size())
655       {
656         // Search for grid source
657         CGrid* gridSrc = grid;
658         CField* currField = this;
659         std::vector<CField*> hieraField;
660
661         while (currField->hasDirectFieldReference() && (gridSrc == grid))
662         {
663           hieraField.push_back(currField);
664           CField* tmp = currField->getDirectFieldReference();
665           currField = tmp;
666           gridSrc = currField->grid;
667         }
668
669         if (gridSrcMap.end() != gridSrcMap.find(gridSrc))
670         {
671           CGrid* gridTmp;
672           std::pair<bool,StdString> newGridDest = gridSrcMap[gridSrc];
673           if (newGridDest.first)
674           {
675             StdString newIdGridDest = newGridDest.second;
676             if (!CGrid::has(newIdGridDest))
677             {
678                ERROR("CGrid* CGrid::generateNewTransformationGridDest()",
679                  << " Something wrong happened! Grid whose id " << newIdGridDest
680                  << "should exist ");
681             }
682             gridTmp = CGrid::get(newIdGridDest);
683           }
684           else
685           {
686             StdString newIdGridDest = CGrid::generateId(gridSrc, grid);
687             gridTmp = CGrid::cloneGrid(newIdGridDest, grid);
688
689             (gridSrcMap[gridSrc]).first = true;
690             (gridSrcMap[gridSrc]).second = newIdGridDest;
691           }
692
693           // Update all descendants
694           for (std::vector<CField*>::iterator it = hieraField.begin(); it != hieraField.end(); ++it)
695           {
696             (*it)->grid = gridTmp;
697             (*it)->updateRef((*it)->grid);
698           }
699         }
700       }
701     }
702   }
703
704   void CField::updateRef(CGrid* grid)
705   {
706     if (!grid_ref.isEmpty()) grid_ref.setValue(grid->getId());
707     else
708     {
709       std::vector<CAxis*> axisTmp = grid->getAxis();
710       std::vector<CDomain*> domainTmp = grid->getDomains();
711       if ((1<axisTmp.size()) || (1<domainTmp.size()))
712         ERROR("void CField::updateRef(CGrid* grid)",
713           << "More than one domain or axis is available for domain_ref/axis_ref of field " << this->getId());
714
715       if ((!domain_ref.isEmpty()) && (domainTmp.empty()))
716         ERROR("void CField::updateRef(CGrid* grid)",
717           << "Incoherent between available domain and domain_ref of field " << this->getId());
718       if ((!axis_ref.isEmpty()) && (axisTmp.empty()))
719         ERROR("void CField::updateRef(CGrid* grid)",
720           << "Incoherent between available axis and axis_ref of field " << this->getId());
721
722       if (!domain_ref.isEmpty()) domain_ref.setValue(domainTmp[0]->getId());
723       if (!axis_ref.isEmpty()) axis_ref.setValue(axisTmp[0]->getId());
724     }
725   }
726
727   void CField::solveAllReferenceEnabledField(bool doSending2Server)
728   {
729     CContext* context = CContext::getCurrent();
730     solveOnlyReferenceEnabledField(doSending2Server);
731
732     if (!areAllReferenceSolved)
733     {
734        areAllReferenceSolved = true;
735
736//        if (context->hasClient)
737        if (context->hasClient && !context->hasServer)
738        {
739          solveRefInheritance(true);
740          if (hasDirectFieldReference()) getDirectFieldReference()->solveAllReferenceEnabledField(false);
741        }
742//        else if (context->hasServer)
743        if (context->hasServer && !context->hasClient)
744          solveServerOperation();
745
746        solveGridReference();
747     }
748
749     solveGridDomainAxisRef(doSending2Server);
750
751     if (context->hasClient && !context->hasClient)
752     {
753       solveTransformedGrid();
754     }
755
756     solveCheckMaskIndex(doSending2Server);
757   }
758
759   std::map<int, StdSize> CField::getGridAttributesBufferSize()
760   {
761     return grid->getAttributesBufferSize();
762   }
763
764   std::map<int, StdSize> CField::getGridDataBufferSize()
765   {
766     return grid->getDataBufferSize(getId());
767   }
768
769   //----------------------------------------------------------------
770
771   void CField::solveServerOperation(void)
772   {
773      CContext* context = CContext::getCurrent();
774
775      if (!context->hasServer || !hasOutputFile) return;
776
777      if (freq_op.isEmpty())
778        freq_op.setValue(TimeStep);
779
780      if (freq_offset.isEmpty())
781        freq_offset.setValue(NoneDu);
782
783      freq_operation_srv = file->output_freq.getValue();
784      freq_write_srv     = file->output_freq.getValue();
785
786      lastlast_Write_srv = context->getCalendar()->getInitDate();
787      last_Write_srv     = context->getCalendar()->getInitDate();
788      last_operation_srv = context->getCalendar()->getInitDate();
789
790      const CDuration toffset = freq_operation_srv - freq_offset.getValue() - context->getCalendar()->getTimeStep();
791      last_operation_srv     = last_operation_srv - toffset;
792
793      if (operation.isEmpty())
794        ERROR("void CField::solveServerOperation(void)",
795              << "An operation must be defined for field \"" << getId() << "\".");
796
797      boost::shared_ptr<func::CFunctor> functor;
798      CArray<double, 1> dummyData;
799
800#define DECLARE_FUNCTOR(MType, mtype) \
801      if (operation.getValue().compare(#mtype) == 0) \
802      { \
803        functor.reset(new func::C##MType(dummyData)); \
804      }
805
806#include "functor_type.conf"
807
808      if (!functor)
809        ERROR("void CField::solveServerOperation(void)",
810              << "\"" << operation << "\" is not a valid operation.");
811
812      operationTimeType = functor->timeType();
813   }
814
815   //----------------------------------------------------------------
816
817   /*!
818    * Constructs the graph filter for the field, enabling or not the data output.
819    * This method should not be called more than once with enableOutput equal to true.
820    *
821    * \param gc the garbage collector to use when building the filter graph
822    * \param enableOutput must be true when the field data is to be
823    *                     read by the client or/and written to a file
824    */
825   void CField::buildFilterGraph(CGarbageCollector& gc, bool enableOutput)
826   {
827     if (!areAllReferenceSolved) solveAllReferenceEnabledField(false);
828
829     // Start by building a filter which can provide the field's instant data
830     if (!instantDataFilter)
831     {
832       // Check if we have an expression to parse
833       if (!content.empty())
834       {
835         boost::scoped_ptr<IFilterExprNode> expr(parseExpr(content + '\0'));
836         instantDataFilter = expr->reduce(gc, *this);
837       }
838       // Check if we have a reference on another field
839       else if (!field_ref.isEmpty())
840         instantDataFilter = getFieldReference(gc);
841       // Check if the data is to be read from a file
842       else if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read)
843         instantDataFilter = serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid,
844                                                                                                     freq_offset.isEmpty() ? NoneDu : freq_offset));
845       else // The data might be passed from the model
846         instantDataFilter = clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid));
847     }
848
849     // If the field data is to be read by the client or/and written to a file
850     if (enableOutput && !storeFilter && !fileWriterFilter)
851     {
852       if (!read_access.isEmpty() && read_access)
853       {
854         storeFilter = boost::shared_ptr<CStoreFilter>(new CStoreFilter(gc, CContext::getCurrent(), grid));
855         instantDataFilter->connectOutput(storeFilter, 0);
856       }
857
858       if (file && (file->mode.isEmpty() || file->mode == CFile::mode_attr::write))
859       {
860         fileWriterFilter = boost::shared_ptr<CFileWriterFilter>(new CFileWriterFilter(gc, this));
861         getTemporalDataFilter(gc, file->output_freq)->connectOutput(fileWriterFilter, 0);
862       }
863     }
864   }
865
866   /*!
867    * Returns the filter needed to handle the field reference.
868    * This method should only be called when building the filter graph corresponding to the field.
869    *
870    * \param gc the garbage collector to use
871    * \return the output pin corresponding to the field reference
872    */
873   boost::shared_ptr<COutputPin> CField::getFieldReference(CGarbageCollector& gc)
874   {
875     if (instantDataFilter || field_ref.isEmpty())
876       ERROR("COutputPin* CField::getFieldReference(CGarbageCollector& gc)",
877             "Impossible to get the field reference for a field which has already been parsed or which does not have a field_ref.");
878
879     CField* fieldRef = CField::get(field_ref);
880     fieldRef->buildFilterGraph(gc, false);
881
882     std::pair<boost::shared_ptr<CFilter>, boost::shared_ptr<CFilter> > filters;
883     // Check if a spatial transformation is needed
884     if (grid && grid != fieldRef->grid && grid->hasTransform())
885     {
886       double defaultValue = 0.0;
887       if (!default_value.isEmpty()) defaultValue = this->default_value;
888       filters = CSpatialTransformFilter::buildFilterGraph(gc, fieldRef->grid, grid, defaultValue);
889     }
890
891     else
892       filters.first = filters.second = boost::shared_ptr<CFilter>(new CPassThroughFilter(gc));
893
894     fieldRef->getInstantDataFilter()->connectOutput(filters.first, 0);
895
896     return filters.second;
897   }
898
899   /*!
900    * Returns the filter needed to handle a self reference in the field's expression.
901    * If the needed filter does not exist, it is created, otherwise it is reused.
902    * This method should only be called when building the filter graph corresponding
903    * to the field's expression.
904    *
905    * \param gc the garbage collector to use
906    * \return the output pin corresponding to a self reference
907    */
908   boost::shared_ptr<COutputPin> CField::getSelfReference(CGarbageCollector& gc)
909   {
910     if (instantDataFilter || content.empty())
911       ERROR("COutputPin* CField::getSelfReference(CGarbageCollector& gc)",
912             "Impossible to add a self reference to a field which has already been parsed or which does not have an expression.");
913
914     if (!selfReferenceFilter)
915     {
916       if (file && !file->mode.isEmpty() && file->mode == CFile::mode_attr::read)
917       {
918         if (!serverSourceFilter)
919           serverSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid,
920                                                                                   freq_offset.isEmpty() ? NoneDu : freq_offset));
921
922         selfReferenceFilter = serverSourceFilter;
923       }
924       else if (!field_ref.isEmpty())
925         selfReferenceFilter = getFieldReference(gc);
926       else
927       {
928         if (!clientSourceFilter)
929           clientSourceFilter = boost::shared_ptr<CSourceFilter>(new CSourceFilter(grid));
930
931         selfReferenceFilter = clientSourceFilter;
932       }
933     }
934
935     return selfReferenceFilter;
936   }
937
938   /*!
939    * Returns the temporal filter corresponding to the field's temporal operation
940    * for the specified operation frequency. The filter is created if it does not
941    * exist, otherwise it is reused.
942    *
943    * \param gc the garbage collector to use
944    * \param outFreq the operation frequency, i.e. the frequency at which the output data will be computed
945    * \return the output pin corresponding to the requested temporal filter
946    */
947   boost::shared_ptr<COutputPin> CField::getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq)
948   {
949     std::map<CDuration, boost::shared_ptr<COutputPin> >::iterator it = temporalDataFilters.find(outFreq);
950
951     if (it == temporalDataFilters.end())
952     {
953       if (operation.isEmpty())
954         ERROR("void CField::getTemporalDataFilter(CGarbageCollector& gc, CDuration outFreq)",
955               << "An operation must be defined for field \"" << getId() << "\".");
956
957       if (freq_op.isEmpty())
958         freq_op.setValue(TimeStep);
959       if (freq_offset.isEmpty())
960         freq_offset.setValue(NoneDu);
961
962       const bool ignoreMissingValue = (!detect_missing_value.isEmpty() && !default_value.isEmpty() && detect_missing_value == true);
963
964       boost::shared_ptr<CTemporalFilter> temporalFilter(new CTemporalFilter(gc, operation,
965                                                                             CContext::getCurrent()->getCalendar()->getInitDate(),
966                                                                             freq_op, freq_offset, outFreq,
967                                                                             ignoreMissingValue, ignoreMissingValue ? default_value : 0.0));
968       instantDataFilter->connectOutput(temporalFilter, 0);
969
970       it = temporalDataFilters.insert(std::make_pair(outFreq, temporalFilter)).first;
971     }
972
973     return it->second;
974   }
975
976   //----------------------------------------------------------------
977/*
978   void CField::fromBinary(StdIStream& is)
979   {
980      SuperClass::fromBinary(is);
981#define CLEAR_ATT(name_)\
982      SuperClassAttribute::operator[](#name_)->reset()
983
984         CLEAR_ATT(domain_ref);
985         CLEAR_ATT(axis_ref);
986#undef CLEAR_ATT
987
988   }
989*/
990   //----------------------------------------------------------------
991
992   void CField::solveGridReference(void)
993   {
994      if (grid_ref.isEmpty() && domain_ref.isEmpty() && axis_ref.isEmpty() && scalar_ref.isEmpty())
995      {
996        ERROR("CField::solveGridReference(void)",
997              << "A grid must be defined for field '" << getFieldOutputName() << "' .");
998      }
999      else if (!grid_ref.isEmpty() && (!domain_ref.isEmpty() || !axis_ref.isEmpty() || !scalar_ref.isEmpty()))
1000      {
1001        ERROR("CField::solveGridReference(void)",
1002              << "Field '" << getFieldOutputName() << "' has both a grid and a domain/axis/scalar." << std::endl
1003              << "Please define either 'grid_ref' or 'domain_ref'/'axis_ref'/'scalar_ref'.");
1004      }
1005
1006      if (grid_ref.isEmpty())
1007      {
1008        std::vector<CDomain*> vecDom;
1009        std::vector<CAxis*> vecAxis;
1010        std::vector<CScalar*> vecScalar;
1011        std::vector<int> axisDomainOrderTmp;
1012       
1013        if (!domain_ref.isEmpty())
1014        {
1015          StdString tmp = domain_ref.getValue();
1016          if (CDomain::has(domain_ref))
1017          {
1018            vecDom.push_back(CDomain::get(domain_ref));
1019            axisDomainOrderTmp.push_back(2);
1020          }
1021          else
1022            ERROR("CField::solveGridReference(void)",
1023                  << "Invalid reference to domain '" << domain_ref.getValue() << "'.");
1024        }
1025
1026        if (!axis_ref.isEmpty())
1027        {
1028          if (CAxis::has(axis_ref))
1029          {
1030            vecAxis.push_back(CAxis::get(axis_ref));
1031            axisDomainOrderTmp.push_back(1);
1032          }
1033          else
1034            ERROR("CField::solveGridReference(void)",
1035                  << "Invalid reference to axis '" << axis_ref.getValue() << "'.");
1036        }
1037
1038        if (!scalar_ref.isEmpty())
1039        {
1040          if (CScalar::has(scalar_ref))
1041          {
1042            vecScalar.push_back(CScalar::get(scalar_ref));
1043            axisDomainOrderTmp.push_back(0);
1044          }
1045          else
1046            ERROR("CField::solveGridReference(void)",
1047                  << "Invalid reference to scalar '" << scalar_ref.getValue() << "'.");
1048        }
1049       
1050        CArray<int,1> axisDomainOrder(axisDomainOrderTmp.size());
1051        for (int idx = 0; idx < axisDomainOrderTmp.size(); ++idx)
1052        {
1053          axisDomainOrder(idx) = axisDomainOrderTmp[idx];
1054        }
1055
1056        // Warning: the gridId shouldn't be set as the grid_ref since it could be inherited
1057        StdString gridId = CGrid::generateId(vecDom, vecAxis, vecScalar,axisDomainOrder);
1058        if (CGrid::has(gridId))
1059          this->grid = CGrid::get(gridId);
1060        else
1061          this->grid = CGrid::createGrid(gridId, vecDom, vecAxis, vecScalar,axisDomainOrder);
1062      }
1063      else
1064      {
1065        if (CGrid::has(grid_ref))
1066          this->grid = CGrid::get(grid_ref);
1067        else
1068          ERROR("CField::solveGridReference(void)",
1069                << "Invalid reference to grid '" << grid_ref.getValue() << "'.");
1070      }
1071   }
1072
1073   void CField::solveGridDomainAxisRef(bool checkAtt)
1074   {
1075     grid->solveDomainAxisRef(checkAtt);
1076   }
1077
1078   void CField::solveCheckMaskIndex(bool doSendingIndex)
1079   {
1080     grid->checkMaskIndex(doSendingIndex);
1081   }
1082
1083   void CField::solveTransformedGrid()
1084   {
1085     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid)
1086     {
1087       std::vector<CGrid*> grids;
1088       // Source grid
1089       grids.push_back(getDirectFieldReference()->grid);
1090       // Intermediate grids
1091       if (!grid_path.isEmpty())
1092       {
1093         std::string gridId;
1094         size_t start = 0, end;
1095
1096         do
1097         {
1098           end = grid_path.getValue().find(',', start);
1099           if (end != std::string::npos)
1100           {
1101             gridId = grid_path.getValue().substr(start, end - start);
1102             start = end + 1;
1103           }
1104           else
1105             gridId = grid_path.getValue().substr(start);
1106
1107           if (!CGrid::has(gridId))
1108             ERROR("void CField::solveTransformedGrid()",
1109                   << "Invalid grid_path, the grid '" << gridId << "' does not exist.");
1110
1111           grids.push_back(CGrid::get(gridId));
1112         }
1113         while (end != std::string::npos);
1114       }
1115       // Destination grid
1116       grids.push_back(grid);
1117
1118       for (size_t i = 0, count = grids.size() - 1; i < count; ++i)
1119       {
1120         CGrid *gridSrc  = grids[i];
1121         CGrid *gridDest = grids[i + 1];
1122         if (!gridDest->isTransformed())
1123           gridDest->transformGrid(gridSrc);
1124       }
1125     }
1126     else if (grid && grid->hasTransform() && !grid->isTransformed())
1127     {
1128       grid->transformGrid(grid);
1129     }
1130   }
1131
1132   void CField::solveGenerateGrid()
1133   {
1134     if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid)
1135       grid->completeGrid(getDirectFieldReference()->grid);
1136     else
1137       grid->completeGrid();
1138   }
1139
1140   void CField::solveGridDomainAxisBaseRef()
1141   {
1142     grid->solveDomainAxisRef(false);
1143     grid->solveDomainAxisBaseRef();
1144   }
1145
1146   ///-------------------------------------------------------------------
1147
1148   template <>
1149   void CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void)
1150   {
1151      if (this->group_ref.isEmpty()) return;
1152      StdString gref = this->group_ref.getValue();
1153
1154      if (!CFieldGroup::has(gref))
1155         ERROR("CGroupTemplate<CField, CFieldGroup, CFieldAttributes>::solveRefInheritance(void)",
1156               << "[ gref = " << gref << "]"
1157               << " invalid group name !");
1158
1159      CFieldGroup* group = CFieldGroup::get(gref);
1160      CFieldGroup* owner = CFieldGroup::get(boost::polymorphic_downcast<CFieldGroup*>(this));
1161
1162      std::vector<CField*> allChildren  = group->getAllChildren();
1163      std::vector<CField*>::iterator it = allChildren.begin(), end = allChildren.end();
1164
1165      for (; it != end; it++)
1166      {
1167         CField* child = *it;
1168         if (child->hasId()) owner->createChild()->field_ref.setValue(child->getId());
1169
1170      }
1171   }
1172
1173   void CField::scaleFactorAddOffset(double scaleFactor, double addOffset)
1174   {
1175     map<int, CArray<double,1> >::iterator it;
1176     for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = (it->second - addOffset) / scaleFactor;
1177   }
1178
1179   void CField::invertScaleFactorAddOffset(double scaleFactor, double addOffset)
1180   {
1181     map<int, CArray<double,1> >::iterator it;
1182     for (it = data_srv.begin(); it != data_srv.end(); it++) it->second = it->second * scaleFactor + addOffset;
1183   }
1184
1185   void CField::outputField(CArray<double,3>& fieldOut)
1186   {
1187      map<int, CArray<double,1> >::iterator it;
1188      for (it = data_srv.begin(); it != data_srv.end(); it++)
1189      {
1190        grid->outputField(it->first, it->second, fieldOut.dataFirst());
1191      }
1192   }
1193
1194   void CField::outputField(CArray<double,2>& fieldOut)
1195   {
1196      map<int, CArray<double,1> >::iterator it;
1197      for(it=data_srv.begin();it!=data_srv.end();it++)
1198      {
1199         grid->outputField(it->first, it->second, fieldOut.dataFirst());
1200      }
1201   }
1202
1203   void CField::outputField(CArray<double,1>& fieldOut)
1204   {
1205      map<int, CArray<double,1> >::iterator it;
1206
1207      for (it = data_srv.begin(); it != data_srv.end(); it++)
1208      {
1209         grid->outputField(it->first, it->second, fieldOut.dataFirst());
1210      }
1211   }
1212
1213   void CField::inputField(CArray<double,3>& fieldOut)
1214   {
1215      map<int, CArray<double,1> >::iterator it;
1216      for (it = data_srv.begin(); it != data_srv.end(); it++)
1217      {
1218        grid->inputField(it->first, fieldOut.dataFirst(), it->second);
1219      }
1220   }
1221
1222   void CField::inputField(CArray<double,2>& fieldOut)
1223   {
1224      map<int, CArray<double,1> >::iterator it;
1225      for(it = data_srv.begin(); it != data_srv.end(); it++)
1226      {
1227         grid->inputField(it->first, fieldOut.dataFirst(), it->second);
1228      }
1229   }
1230
1231   void CField::inputField(CArray<double,1>& fieldOut)
1232   {
1233      map<int, CArray<double,1> >::iterator it;
1234      for (it = data_srv.begin(); it != data_srv.end(); it++)
1235      {
1236         grid->inputField(it->first, fieldOut.dataFirst(), it->second);
1237      }
1238   }
1239
1240   void CField::outputCompressedField(CArray<double,1>& fieldOut)
1241   {
1242      map<int, CArray<double,1> >::iterator it;
1243
1244      for (it = data_srv.begin(); it != data_srv.end(); it++)
1245      {
1246         grid->outputCompressedField(it->first, it->second, fieldOut.dataFirst());
1247      }
1248   }
1249
1250   ///-------------------------------------------------------------------
1251
1252   void CField::parse(xml::CXMLNode& node)
1253   {
1254      SuperClass::parse(node);
1255      if (!node.getContent(this->content))
1256      {
1257        if (node.goToChildElement())
1258        {
1259          do
1260          {
1261            if (node.getElementName() == "variable" || node.getElementName() == "variable_group") this->getVirtualVariableGroup()->parseChild(node);
1262          } while (node.goToNextElement());
1263          node.goToParentElement();
1264        }
1265      }
1266    }
1267
1268   /*!
1269     This function retrieves Id of corresponding domain_ref and axis_ref (if any)
1270   of a field. In some cases, only domain exists but axis doesn't
1271   \return pair of Domain and Axis id
1272   */
1273   const std::vector<StdString>& CField::getRefDomainAxisIds()
1274   {
1275     CGrid* cgPtr = getRelGrid();
1276     if (NULL != cgPtr)
1277     {
1278       std::vector<StdString>::iterator it;
1279       if (!domain_ref.isEmpty())
1280       {
1281         std::vector<StdString> domainList = cgPtr->getDomainList();
1282         it = std::find(domainList.begin(), domainList.end(), domain_ref.getValue());
1283         if (domainList.end() != it) domAxisScalarIds_[0] = *it;
1284       }
1285
1286       if (!axis_ref.isEmpty())
1287       {
1288         std::vector<StdString> axisList = cgPtr->getAxisList();
1289         it = std::find(axisList.begin(), axisList.end(), axis_ref.getValue());
1290         if (axisList.end() != it) domAxisScalarIds_[1] = *it;
1291       }
1292
1293       if (!scalar_ref.isEmpty())
1294       {
1295         std::vector<StdString> scalarList = cgPtr->getScalarList();
1296         it = std::find(scalarList.begin(), scalarList.end(), scalar_ref.getValue());
1297         if (scalarList.end() != it) domAxisScalarIds_[2] = *it;
1298       }
1299     }
1300     return (domAxisScalarIds_);
1301   }
1302
1303   CVariable* CField::addVariable(const string& id)
1304   {
1305     return vVariableGroup->createChild(id);
1306   }
1307
1308   CVariableGroup* CField::addVariableGroup(const string& id)
1309   {
1310     return vVariableGroup->createChildGroup(id);
1311   }
1312
1313   void CField::sendAddAllVariables()
1314   {
1315     std::vector<CVariable*> allVar = getAllVariables();
1316     std::vector<CVariable*>::const_iterator it = allVar.begin();
1317     std::vector<CVariable*>::const_iterator itE = allVar.end();
1318
1319     for (; it != itE; ++it)
1320     {
1321       this->sendAddVariable((*it)->getId());
1322       (*it)->sendAllAttributesToServer();
1323       (*it)->sendValue();
1324     }
1325   }
1326
1327   void CField::sendAddAllVariables(const int srvPool)
1328   {
1329     std::vector<CVariable*> allVar = getAllVariables();
1330     std::vector<CVariable*>::const_iterator it = allVar.begin();
1331     std::vector<CVariable*>::const_iterator itE = allVar.end();
1332
1333     for (; it != itE; ++it)
1334     {
1335       this->sendAddVariable((*it)->getId());
1336       (*it)->sendAllAttributesToServer(srvPool);
1337       (*it)->sendValue(srvPool);
1338     }
1339   }
1340
1341   void CField::sendAddVariable(const string& id)
1342   {
1343      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE);
1344    // CContext* context = CContext::getCurrent();
1345
1346    // if (!context->hasServer)
1347    // {
1348    //    CContextClient* client = context->client;
1349
1350    //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE);
1351    //    if (client->isServerLeader())
1352    //    {
1353    //      CMessage msg;
1354    //      msg << this->getId();
1355    //      msg << id;
1356    //      const std::list<int>& ranks = client->getRanksServerLeader();
1357    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
1358    //        event.push(*itRank,1,msg);
1359    //      client->sendEvent(event);
1360    //    }
1361    //    else client->sendEvent(event);
1362    // }
1363   }
1364
1365   void CField::sendAddVariableGroup(const string& id)
1366   {
1367      sendAddItem(id, (int)EVENT_ID_ADD_VARIABLE_GROUP);
1368    // CContext* context = CContext::getCurrent();
1369    // if (!context->hasServer)
1370    // {
1371    //    CContextClient* client = context->client;
1372
1373    //    CEventClient event(this->getType(),EVENT_ID_ADD_VARIABLE_GROUP);
1374    //    if (client->isServerLeader())
1375    //    {
1376    //      CMessage msg;
1377    //      msg << this->getId();
1378    //      msg << id;
1379    //      const std::list<int>& ranks = client->getRanksServerLeader();
1380    //      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)
1381    //        event.push(*itRank,1,msg);
1382    //      client->sendEvent(event);
1383    //    }
1384    //    else client->sendEvent(event);
1385    // }
1386   }
1387
1388   void CField::recvAddVariable(CEventServer& event)
1389   {
1390
1391      CBufferIn* buffer = event.subEvents.begin()->buffer;
1392      string id;
1393      *buffer >> id;
1394      get(id)->recvAddVariable(*buffer);
1395   }
1396
1397   void CField::recvAddVariable(CBufferIn& buffer)
1398   {
1399      string id;
1400      buffer >> id;
1401      addVariable(id);
1402   }
1403
1404   void CField::recvAddVariableGroup(CEventServer& event)
1405   {
1406
1407      CBufferIn* buffer = event.subEvents.begin()->buffer;
1408      string id;
1409      *buffer >> id;
1410      get(id)->recvAddVariableGroup(*buffer);
1411   }
1412
1413   void CField::recvAddVariableGroup(CBufferIn& buffer)
1414   {
1415      string id;
1416      buffer >> id;
1417      addVariableGroup(id);
1418   }
1419
1420   DEFINE_REF_FUNC(Field,field)
1421} // namespace xios
Note: See TracBrowser for help on using the repository browser.