source: XIOS3/dev/XIOS_ATTACHED/src/node/scalar.cpp @ 2482

Last change on this file since 2482 was 2482, checked in by ymipsl, 15 months ago

First guess in supression of attached mode replaced by online reader and write filters

YM

File size: 22.6 KB
Line 
1#include "scalar.hpp"
2
3#include "attribute_template.hpp"
4#include "object_template.hpp"
5#include "group_template.hpp"
6#include "object_factory.hpp"
7#include "xios_spl.hpp"
8#include "type.hpp"
9#include "context.hpp"
10
11#include <algorithm>
12#include <regex>
13
14namespace xios
15{
16
17  /// ////////////////////// Définitions ////////////////////// ///
18
19  CScalar::CScalar(void)
20     : CObjectTemplate<CScalar>()
21     , CScalarAttributes()
22     , relFiles()
23  { /* Ne rien faire de plus */ }
24
25  CScalar::CScalar(const StdString & id)
26     : CObjectTemplate<CScalar>(id)
27     , CScalarAttributes()
28     , relFiles()
29  { /* Ne rien faire de plus */ }
30
31  CScalar::~CScalar(void)
32  { /* Ne rien faire de plus */ }
33
34  void CScalar::releaseStaticAllocation(void)
35  {
36    transformationMapList_.clear() ;
37    CTransformation<CScalar>::unregisterAllTransformations() ;
38    CGridTransformationFactory<CScalar>::unregisterAllTransformations() ;
39  }
40 
41  std::map<StdString, ETranformationType> CScalar::transformationMapList_ = std::map<StdString, ETranformationType>();
42  bool CScalar::dummyTransformationMapList_ = CScalar::initializeTransformationMap(CScalar::transformationMapList_);
43  bool CScalar::initializeTransformationMap(std::map<StdString, ETranformationType>& m)
44  {
45    m["reduce_axis"]   = TRANS_REDUCE_AXIS_TO_SCALAR;
46    m["extract_axis"]  = TRANS_EXTRACT_AXIS_TO_SCALAR;
47    m["reduce_domain"] = TRANS_REDUCE_DOMAIN_TO_SCALAR;
48    m["reduce_scalar"] = TRANS_REDUCE_SCALAR_TO_SCALAR;
49    m["redistribute_scalar"] = TRANS_REDISTRIBUTE_SCALAR;
50    return true;
51  }
52
53  StdString CScalar::GetName(void)   { return (StdString("scalar")); }
54  StdString CScalar::GetDefName(void){ return (CScalar::GetName()); }
55  ENodeType CScalar::GetType(void)   { return (eScalar); }
56
57  CScalar* CScalar::createScalar()
58  {
59    CScalar* scalar = CScalarGroup::get("scalar_definition")->createChild();
60    return scalar;
61  }
62
63  CScalar* CScalar::get(const string& id, bool noError)
64  {
65    const regex r("::");
66    smatch m;
67    if (regex_search(id, m, r))
68    {
69      if (m.size()!=1) ERROR("CScalar* CScalar::get(string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time");
70      string fieldId=m.prefix() ;
71      if (fieldId.empty()) ERROR("CScalar* CScalar::get(string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty");
72      string suffix=m.suffix() ;
73      if (!CField::has(fieldId)) 
74          if (noError)  return nullptr ;
75          else ERROR("CScalar* CScalar::get(const string& id, bool noError)", <<" id = "<<id<< "  -> field Id : < "<<fieldId<<" > doesn't exist");
76      CField* field=CField::get(fieldId) ;
77      return field->getAssociatedScalar(suffix, noError) ;
78    }
79    else
80    {
81       if (noError) if(!CObjectFactory::HasObject<CScalar>(id)) return nullptr ;
82       return CObjectFactory::GetObject<CScalar>(id).get();
83     }
84   }
85
86   bool CScalar::has(const string& id)
87   {
88     if (CScalar::get(id,true)==nullptr) return false ;
89     else return true ;
90   }
91   
92   CField* CScalar::getFieldFromId(const string& id)
93   {
94     const regex r("::");
95     smatch m;
96     if (regex_search(id, m, r))
97     {
98        if (m.size()!=1) ERROR("CField* CScalar::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, separator :: append more than one time");
99        string fieldId=m.prefix() ;
100        if (fieldId.empty()) ERROR("CField* CScalar::getFieldFromId(const string& id)", <<" id = "<<id<< "  -> bad format id, field name is empty");
101        string suffix=m.suffix() ;
102        CField* field=CField::get(fieldId) ;
103        return field ;
104     }
105     else return nullptr;
106   }
107
108  bool CScalar::IsWritten(const StdString & filename) const
109  {
110    return (this->relFiles.find(filename) != this->relFiles.end());
111  }
112
113  void CScalar::addRelFile(const StdString& filename)
114  {
115      this->relFiles.insert(filename);
116  }
117
118  void CScalar::checkAttributes(void)
119  {
120    if (checkAttributes_done_) return ;
121    checkAttributes_done_ = true ; 
122   
123    if (n.isEmpty()) n=1 ;
124    if (mask.isEmpty()) mask=true ;
125   
126    hasValue_ =  (value.isEmpty())  ? false :true ;
127    hasBounds_ = (bounds.isEmpty()) ? false :true ;
128    hasLabel_ =  (label.isEmpty())  ? false :true ;
129
130
131    initializeLocalElement() ;
132    addFullView() ;
133    addWorkflowView() ;
134    addModelView() ;
135  }
136
137  /*!
138    Compare two scalar objects.
139    They are equal if only if they have identical attributes as well as their values.
140    Moreover, they must have the same transformations.
141  \param [in] scalar Compared scalar
142  \return result of the comparison
143  */
144  bool CScalar::isEqual(CScalar* obj)
145  {
146    vector<StdString> excludedAttr;
147    excludedAttr.push_back("scalar_ref");
148    bool objEqual = SuperClass::isEqual(obj, excludedAttr);
149    if (!objEqual) return objEqual;
150
151    TransMapTypes thisTrans = this->getAllTransformations();
152    TransMapTypes objTrans  = obj->getAllTransformations();
153
154    TransMapTypes::const_iterator it, itb, ite;
155    std::vector<ETranformationType> thisTransType, objTransType;
156    for (it = thisTrans.begin(); it != thisTrans.end(); ++it)
157      thisTransType.push_back(it->first);
158    for (it = objTrans.begin(); it != objTrans.end(); ++it)
159      objTransType.push_back(it->first);
160
161    if (thisTransType.size() != objTransType.size()) return false;
162    for (int idx = 0; idx < thisTransType.size(); ++idx)
163      objEqual &= (thisTransType[idx] == objTransType[idx]);
164
165    return objEqual;
166  }
167
168  CTransformation<CScalar>* CScalar::addTransformation(ETranformationType transType, const StdString& id)
169  {
170    transformationMap_.push_back(std::make_pair(transType, CTransformation<CScalar>::createTransformation(transType,id)));
171    return transformationMap_.back().second;
172  }
173
174  bool CScalar::hasTransformation()
175  {
176    return (!transformationMap_.empty());
177  }
178
179  void CScalar::setTransformations(const TransMapTypes& scalarTrans)
180  {
181    transformationMap_ = scalarTrans;
182  }
183
184  CScalar::TransMapTypes CScalar::getAllTransformations(void)
185  {
186    return transformationMap_;
187  }
188
189  void CScalar::duplicateTransformation(CScalar* src)
190  {
191    if (src->hasTransformation())
192    {
193      this->setTransformations(src->getAllTransformations());
194    }
195  }
196
197  /*!
198   * Go through the hierarchy to find the scalar from which the transformations must be inherited
199   */
200  void CScalar::solveInheritanceTransformation_old()
201  {
202    if (hasTransformation() || !hasDirectScalarReference())
203      return;
204
205    CScalar* scalar = this;
206    std::vector<CScalar*> refScalar;
207    while (!scalar->hasTransformation() && scalar->hasDirectScalarReference())
208    {
209      refScalar.push_back(scalar);
210      scalar = scalar->getDirectScalarReference();
211    }
212
213    if (scalar->hasTransformation())
214      for (size_t i = 0; i < refScalar.size(); ++i)
215        refScalar[i]->setTransformations(scalar->getAllTransformations());
216  }
217 
218  void CScalar::solveInheritanceTransformation()
219  TRY
220  {
221    if (solveInheritanceTransformation_done_) return;
222    else solveInheritanceTransformation_done_=true ;
223
224    CScalar* scalar = this;
225    CScalar* Lastscalar ;
226    std::list<CScalar*> refScalars;
227    bool out=false ;
228    vector<StdString> excludedAttr;
229    excludedAttr.push_back("scalar_ref");
230   
231    refScalars.push_front(scalar) ;
232    while (scalar->hasDirectScalarReference() && !out)
233    {
234      CScalar* lastScalar=scalar ;
235      scalar = scalar->getDirectScalarReference();
236      scalar->solveRefInheritance() ;
237      if (!scalar->SuperClass::isEqual(lastScalar,excludedAttr)) out=true ;
238      refScalars.push_front(scalar) ;
239    }
240
241    CTransformationPaths::TPath path ;
242    auto& pathList = std::get<2>(path) ;
243    std::get<0>(path) = EElement::SCALAR ;
244    std::get<1>(path) = refScalars.front()->getId() ;
245    for (auto& scalar : refScalars)
246    {
247      CScalar::TransMapTypes transformations = scalar->getAllTransformations();
248      for(auto& transformation : transformations) pathList.push_back({transformation.second->getTransformationType(), 
249                                                                      transformation.second->getId()}) ;
250    }
251    transformationPaths_.addPath(path) ;
252
253  }
254  CATCH_DUMP_ATTR
255
256  bool CScalar::activateFieldWorkflow(CGarbageCollector& gc)
257  TRY
258  {
259    if (!scalar_ref.isEmpty())
260    {
261      CField* field=getFieldFromId(scalar_ref) ;
262      if (field!=nullptr)
263      {
264        bool ret = field->buildWorkflowGraph(gc) ;
265        if (!ret) return false ; // cannot build workflow graph at this state
266      }
267      else 
268      {
269        CScalar* scalar = get(scalar_ref) ;
270        bool ret = scalar->activateFieldWorkflow(gc) ;
271        if (!ret) return false ; // cannot build workflow graph at this state
272        scalar_ref=scalar->getId() ; // replace domain_ref by solved reference
273      }
274    }
275    activateFieldWorkflow_done_=true ;
276    return true ;
277  }
278  CATCH_DUMP_ATTR
279
280
281  /* obsolete, to remove after reimplementing coupling */
282  void CScalar::sendScalarToCouplerOut(CContextClient* client, const string& fieldId, int posInGrid)
283  {
284    if (sendScalarToCouplerOut_done_.count(client)!=0) return ;
285    else sendScalarToCouplerOut_done_.insert(client) ;
286
287    string scalarId = getCouplingAlias(fieldId, posInGrid) ;
288
289    this->sendAllAttributesToServer(client, scalarId);
290  } 
291
292  string CScalar::getCouplingAlias(const string& fieldId, int posInGrid)
293  {
294    return "_scalar["+std::to_string(posInGrid)+"]_of_"+fieldId ;
295  }
296
297  void CScalar::makeAliasForCoupling(const string& fieldId, int posInGrid)
298  {
299    const string scalarId = getCouplingAlias(fieldId, posInGrid) ;
300    this->createAlias(scalarId) ;
301  }
302
303  void CScalar::setContextClient(CContextClient* contextClient)
304  TRY
305  {
306    if (clientsSet.find(contextClient)==clientsSet.end())
307    {
308      clients.push_back(contextClient) ;
309      clientsSet.insert(contextClient);
310    }
311  }
312  CATCH_DUMP_ATTR
313  /*!
314    Parse children nodes of a scalar in xml file.
315    \param node child node to process
316  */
317  void CScalar::parse(xml::CXMLNode & node)
318  {
319    SuperClass::parse(node);
320
321    if (node.goToChildElement())
322    {
323      StdString nodeElementName;
324      do
325      {
326        StdString nodeId("");
327        if (node.getAttributes().end() != node.getAttributes().find("id"))
328        { nodeId = node.getAttributes()["id"]; }
329
330        nodeElementName = node.getElementName();
331        std::map<StdString, ETranformationType>::const_iterator ite = transformationMapList_.end(), it;
332        it = transformationMapList_.find(nodeElementName);
333        if (ite != it)
334        {
335          transformationMap_.push_back(std::make_pair(it->second, CTransformation<CScalar>::createTransformation(it->second,
336                                                                                                                 nodeId,
337                                                                                                                 &node)));
338        }
339        else
340        {
341          ERROR("void CScalar::parse(xml::CXMLNode & node)",
342                << "The transformation " << nodeElementName << " has not been supported yet.");
343        }
344      } while (node.goToNextElement()) ;
345      node.goToParentElement();
346    }
347  }
348
349   //////////////////////////////////////////////////////////////////////////////////////
350   //  this part is related to distribution, element definition, views and connectors  //
351   //////////////////////////////////////////////////////////////////////////////////////
352
353   void CScalar::initializeLocalElement(void)
354   {
355      // after checkAttribute index of size n
356      int rank = CContext::getCurrent()->getIntraCommRank() ;
357     
358     
359      CArray<size_t,1> index(n) ;
360      if (n==1) index(0)=0 ;
361      localElement_ = make_shared<CLocalElement>(rank, 1, index) ;
362   }
363
364   void CScalar::addFullView(void)
365   {
366      CArray<int,1> index(n) ;
367      if (n==1) index(0)=0 ;
368      localElement_ -> addView(CElementView::FULL, index) ;
369   }
370
371   void CScalar::addWorkflowView(void)
372   {
373      CArray<int,1> index ;
374      if (mask && n==1)
375      {
376        index.resize(1) ;
377        index(0)=0 ;
378      }
379      else index.resize(0) ;
380      localElement_ -> addView(CElementView::WORKFLOW, index) ;
381   }
382
383   void CScalar::addModelView(void)
384   {
385     CArray<int,1> index(1) ;
386     for(int i=0; i<1 ; i++) index(0)=0 ;
387     localElement_->addView(CElementView::MODEL, index) ;
388   }
389
390   void CScalar::computeModelToWorkflowConnector(void)
391   { 
392     shared_ptr<CLocalView> srcView=getLocalView(CElementView::MODEL) ;
393     shared_ptr<CLocalView> dstView=getLocalView(CElementView::WORKFLOW) ;
394     modelToWorkflowConnector_ = make_shared<CLocalConnector>(srcView, dstView); 
395     modelToWorkflowConnector_->computeConnector() ;
396   }
397
398
399  void CScalar::computeRemoteElement(CContextClient* client, EDistributionType type)
400  {
401    CContext* context = CContext::getCurrent();
402    map<int, CArray<size_t,1>> globalIndex ;
403    size_t nglo=1 ;
404
405    if (type==EDistributionType::ROOT) // Bands distribution to send to file server
406    {
407      for (auto& rankServer : client->getRanksServerLeader())
408      {
409        auto& globalInd =  globalIndex[rankServer] ;
410        if (rankServer==0) 
411        {
412          globalInd.resize(1) ;
413          globalInd(0)=0 ;
414        }
415      }
416    }
417    else if (type==EDistributionType::NONE) // domain is not distributed ie all servers get the same local domain
418    {
419      int nbServer = client->getRemoteSize();
420      CArray<size_t,1> indGlo(nglo) ;
421      for(size_t i=0;i<nglo;i++) indGlo(i) = i ;
422      for (auto& rankServer : client->getRanksServerLeader()) globalIndex[rankServer].reference(indGlo.copy()) ; 
423    }
424    remoteElement_[client] = make_shared<CDistributedElement>(nglo, globalIndex) ;
425    remoteElement_[client]->addFullView() ;
426  }
427 
428  void CScalar::distributeToServer(CContextClient* client, bool inOut, std::map<int, CArray<size_t,1>>& globalIndexOut,  std::map<int, CArray<size_t,1>>& globalIndexIn, 
429                                   shared_ptr<CScattererConnector> &scattererConnector, const string& scalarId)
430  {
431    string serverScalarId = scalarId.empty() ? this->getId() : scalarId ;
432    CContext* context = CContext::getCurrent();
433
434    this->sendAllAttributesToServer(client, serverScalarId)  ;
435
436    auto scatteredElement = make_shared<CDistributedElement>(1,globalIndexOut) ;
437    scatteredElement->addFullView() ;
438    scattererConnector = make_shared<CScattererConnector>(localElement_->getView(CElementView::FULL), scatteredElement->getView(CElementView::FULL), 
439                                                          context->getIntraComm(), client->getRemoteSize()) ;
440    scattererConnector->computeConnector() ;
441   
442    // phase 0
443    // send remote element to construct the full view on server, ie without hole
444    CEventClient event0(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
445    CMessage message0 ;
446    message0<<serverScalarId<<0 ; 
447    remoteElement_[client]->sendToServer(client,event0,message0) ; 
448   
449    // phase 1
450    // send the full view of element to construct the connector which connect distributed data coming from client to the full local view
451    CEventClient event1(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
452    CMessage message1 ;
453    message1<<serverScalarId<<1<<localElement_->getView(CElementView::FULL)->getGlobalSize() ; 
454    scattererConnector->transfer(localElement_->getView(CElementView::FULL)->getGlobalIndex(),client,event1,message1) ;
455
456    sendDistributedAttributes(client, scattererConnector, scalarId) ;
457 
458    // phase 2 send the mask : data index + mask2D
459    {
460      CArray<bool,1> maskIn(localElement_->getView(CElementView::WORKFLOW)->getSize());
461      CArray<bool,1> maskOut ;
462      auto workflowToFull = make_shared<CLocalConnector>(localElement_->getView(CElementView::WORKFLOW), localElement_->getView(CElementView::FULL)) ;
463      workflowToFull->computeConnector() ;
464      maskIn=true ;
465      workflowToFull->transfer(maskIn,maskOut,false) ;
466
467      // prepare grid scatterer connector to send data from client to server
468      map<int,CArray<size_t,1>> workflowGlobalIndex ;
469      map<int,CArray<bool,1>> maskOut2 ; 
470      scattererConnector->transfer(maskOut, maskOut2) ;
471      scatteredElement->addView(CElementView::WORKFLOW, maskOut2) ;
472      scatteredElement->getView(CElementView::WORKFLOW)->getGlobalIndexView(workflowGlobalIndex) ;
473      // create new workflow view for scattered element
474      auto clientToServerElement = make_shared<CDistributedElement>(scatteredElement->getGlobalSize(), workflowGlobalIndex) ;
475      clientToServerElement->addFullView() ;
476      CEventClient event2(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
477      CMessage message2 ;
478      message2<<serverScalarId<<2 ; 
479      clientToServerElement->sendToServer(client, event2, message2) ; 
480      clientToServerConnector_[client] = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), clientToServerElement->getView(CElementView::FULL),
481                                                                          context->getIntraComm(), client->getRemoteSize()) ;
482      clientToServerConnector_[client]->computeConnector() ;
483    }
484
485    ////////////
486    // phase 3 : compute connector to receive from server
487    ////////////
488    if (inOut)
489    {
490      auto scatteredElement = make_shared<CDistributedElement>(1, globalIndexIn) ;
491      scatteredElement->addFullView() ;
492      auto scattererConnector = make_shared<CScattererConnector>(localElement_->getView(CElementView::FULL), scatteredElement->getView(CElementView::FULL), 
493                                                                 context->getIntraComm(), client->getRemoteSize()) ;
494      scattererConnector->computeConnector() ;
495 
496      CArray<bool,1> maskIn(localElement_->getView(CElementView::WORKFLOW)->getSize());
497      CArray<bool,1> maskOut ;
498      auto workflowToFull = make_shared<CLocalConnector>(localElement_->getView(CElementView::WORKFLOW), localElement_->getView(CElementView::FULL)) ;
499      workflowToFull->computeConnector() ;
500      maskIn=true ;
501      workflowToFull->transfer(maskIn,maskOut,false) ;
502
503      map<int,CArray<size_t,1>> workflowGlobalIndex ;
504      map<int,CArray<bool,1>> maskOut2 ; 
505      scattererConnector->transfer(maskOut, maskOut2, false) ;
506      scatteredElement->addView(CElementView::WORKFLOW, maskOut2) ;
507      scatteredElement->getView(CElementView::WORKFLOW)->getGlobalIndexView(workflowGlobalIndex) ;
508      auto clientToServerElement = make_shared<CDistributedElement>(scatteredElement->getGlobalSize(), workflowGlobalIndex) ;
509      clientToServerElement->addFullView() ;
510      CEventClient event3(getType(), EVENT_ID_SCALAR_DISTRIBUTION);
511      CMessage message3 ;
512      message3<<serverScalarId<<3 ; 
513      clientToServerElement->sendToServer(client, event3, message3) ; 
514
515      clientFromServerConnector_[client] = make_shared<CGathererConnector>(clientToServerElement->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW));
516      clientFromServerConnector_[client]->computeConnector() ;     
517    }
518  }
519 
520  void CScalar::recvScalarDistribution(CEventServer& event)
521  TRY
522  {
523    string scalarId;
524    int phasis ;
525    for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> scalarId >> phasis ;
526    get(scalarId)->receivedScalarDistribution(event, phasis);
527  }
528  CATCH
529 
530  void CScalar::receivedScalarDistribution(CEventServer& event, int phasis)
531  TRY
532  {
533    CContext* context = CContext::getCurrent();
534    if (phasis==0) // receive the remote element to construct the full view
535    {
536      localElement_ = make_shared<CLocalElement>(context->getIntraCommRank(),event) ;
537      localElement_->addFullView() ;
538      // construct the local dimension and indexes
539      auto& globalIndex=localElement_->getGlobalIndex() ;
540      n=globalIndex.numElements() ;
541      // no distribution for scalar => nk ==1 or maybe 0 ?
542    }
543    else if (phasis==1) // receive the sent view from client to construct the full distributed full view on server
544    {
545      CContext* context = CContext::getCurrent();
546      shared_ptr<CDistributedElement> elementFrom = make_shared<CDistributedElement>(event) ;
547      elementFrom->addFullView() ;
548      gathererConnector_ = make_shared<CGathererConnector>(elementFrom->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ;
549      gathererConnector_->computeConnector() ; 
550    }
551    else if (phasis==2)
552    {
553//      delete gathererConnector_ ;
554      elementFrom_ = make_shared<CDistributedElement>(event) ;
555      elementFrom_->addFullView() ;
556//      gathererConnector_ =  make_shared<CGathererConnector>(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::FULL)) ;
557//      gathererConnector_ -> computeConnector() ;
558    }
559    else if (phasis==3)
560    {
561      elementTo_ = make_shared<CDistributedElement>(event) ;
562      elementTo_->addFullView() ;
563    }
564  }
565  CATCH
566
567  void CScalar::setServerMask(CArray<bool,1>& serverMask, CContextClient* client)
568  TRY
569  {
570    CContext* context = CContext::getCurrent();
571    localElement_->addView(CElementView::WORKFLOW, serverMask) ;
572    if (serverMask.numElements()==1) mask = serverMask(0) ;
573 
574    serverFromClientConnector_ = make_shared<CGathererConnector>(elementFrom_->getView(CElementView::FULL), localElement_->getView(CElementView::WORKFLOW)) ;
575    serverFromClientConnector_->computeConnector() ;
576    elementFrom_.reset() ;
577     
578    if (elementTo_)
579    {
580      serverToClientConnector_ = make_shared<CScattererConnector>(localElement_->getView(CElementView::WORKFLOW), elementTo_->getView(CElementView::FULL),
581                                                                context->getIntraComm(), client->getRemoteSize()) ;
582      serverToClientConnector_->computeConnector() ;
583      elementTo_.reset() ;
584    }
585  }
586  CATCH_DUMP_ATTR
587
588  void CScalar::sendDistributedAttributes(CContextClient* client, shared_ptr<CScattererConnector> scattererConnector, const string& scalarId)
589  {
590    string serverScalarId = scalarId.empty() ? this->getId() : scalarId ;
591    CContext* context = CContext::getCurrent();
592
593    // nothing for now
594  }
595
596  void CScalar::recvDistributedAttributes(CEventServer& event)
597  TRY
598  {
599    string scalarId;
600    string type ;
601    for (auto& subEvent : event.subEvents) (*subEvent.buffer) >> scalarId >> type ;
602    get(scalarId)->recvDistributedAttributes(event, type);
603  }
604  CATCH
605
606  void CScalar::recvDistributedAttributes(CEventServer& event, const string& type)
607  TRY
608  {
609    // nothing for now
610  }
611  CATCH 
612
613  bool CScalar::dispatchEvent(CEventServer& event)
614  TRY
615  {
616     if (SuperClass::dispatchEvent(event)) return true;
617     else
618     {
619       switch(event.type)
620       {
621          case EVENT_ID_SCALAR_DISTRIBUTION:
622            recvScalarDistribution(event);
623            return true;
624            break;
625          case EVENT_ID_SEND_DISTRIBUTED_ATTRIBUTE:
626            recvDistributedAttributes(event);
627            return true;
628            break;
629          default :
630            ERROR("bool CScalar::dispatchEvent(CEventServer& event)",
631                   << "Unknown Event");
632          return false;
633        }
634     }
635  }
636  CATCH
637
638
639  // Definition of some macros
640  DEFINE_REF_FUNC(Scalar,scalar)
641
642} // namespace xios
Note: See TracBrowser for help on using the repository browser.