FACT++  1.0
int StateMachineDimControl::HandleServerAdd ( const std::string &  server)

Definition at line 394 of file StateMachineDimControl.cc.

References HandleDescriptions(), HandleStateChange(), HandleStates(), DimState::server, DimState::SetCallback(), DimDescriptions::SetCallbackDescriptions(), DimDescribedState::SetCallbackStates(), and DimDescriptions::Subscribe().

Referenced by StateMachineDimControl().

395 {
396  if (server!="DIS_DNS")
397  {
398  struct Find : string
399  {
400  Find(const string &ref) : string(ref) { }
401  bool operator()(const DimDescriptions *dim) { return *this==dim->server; }
402  };
403 
404  if (find_if(fDimDescriptionsList.begin(), fDimDescriptionsList.end(),
405  Find(server))==fDimDescriptionsList.end())
406  {
407  DimDescriptions *d = new DimDescriptions(server);
408 
409  fDimDescriptionsList.push_back(d);
410  d->SetCallback(bind(&StateMachineDimControl::HandleStateChange, this, server, d));
411  d->SetCallbackStates(bind(&StateMachineDimControl::HandleStates, this, server, d));
413  d->Subscribe(*this);
414  }
415  }
416 
417  // Make a copy of the list to be able to
418  // lock the access to the list
419 
420  const lock_guard<mutex> guard(fMutex);
421  fServerList.insert(server);
422 
423  return GetCurrentState();
424 }
std::ostream & operator()() const
Definition: MessageImp.h:72
int GetCurrentState() const
return the current state of the machine
int HandleStates(const std::string &server, DimDescriptions *state)
int HandleDescriptions(DimDescriptions *state)
std::string server
Definition: DimState.h:61
int HandleStateChange(const std::string &server, DimDescriptions *state)
void SetCallbackStates(const callback_desc &cb)
Definition: DimState.h:142
void SetCallbackDescriptions(const callback_desc &cb)
Definition: DimState.h:197
std::vector< DimDescriptions * > fDimDescriptionsList
virtual void Subscribe(StateMachineImp &imp)
Definition: DimState.h:189
std::set< std::string > fServerList
void SetCallback(const callback &cb)
Definition: DimState.h:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function: