CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/EventFilter/StorageManager/src/StateMachineMonitorCollection.cc

Go to the documentation of this file.
00001 // $Id: StateMachineMonitorCollection.cc,v 1.9 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/Exception.h"
00005 #include "EventFilter/StorageManager/interface/StateMachineMonitorCollection.h"
00006 
00007 
00008 namespace stor {
00009   
00010   StateMachineMonitorCollection::StateMachineMonitorCollection(const utils::Duration_t& updateInterval) :
00011   MonitorCollection(updateInterval),
00012   externallyVisibleState_( "unknown" ),
00013   stateName_( "unknown" )
00014   {}
00015   
00016 
00017   void StateMachineMonitorCollection::updateHistory( const TransitionRecord& tr )
00018   {
00019     boost::mutex::scoped_lock sl( stateMutex_ );
00020     history_.push_back( tr );
00021   }
00022   
00023   
00024   void StateMachineMonitorCollection::getHistory( History& history ) const
00025   {
00026     boost::mutex::scoped_lock sl( stateMutex_ );
00027     history = history_;
00028   }
00029   
00030   
00031   void StateMachineMonitorCollection::dumpHistory( std::ostream& os ) const
00032   {
00033     boost::mutex::scoped_lock sl( stateMutex_ );
00034     
00035     os << "**** Begin transition history ****" << std::endl;
00036     
00037     for( History::const_iterator j = history_.begin();
00038          j != history_.end(); ++j )
00039     {
00040       os << "  " << *j << std::endl;
00041     }
00042     
00043     os << "**** End transition history ****" << std::endl;
00044     
00045   }
00046   
00047   
00048   void StateMachineMonitorCollection::setExternallyVisibleState( const std::string& n )
00049   {
00050     boost::mutex::scoped_lock sl( stateMutex_ );
00051     externallyVisibleState_ = n;
00052   }
00053   
00054   
00055   const std::string& StateMachineMonitorCollection::externallyVisibleState() const
00056   {
00057     boost::mutex::scoped_lock sl( stateMutex_ );
00058     return externallyVisibleState_;
00059   }
00060   
00061   
00062   void StateMachineMonitorCollection::setStatusMessage( const std::string& m )
00063   {
00064     boost::mutex::scoped_lock sl( stateMutex_ );
00065     if ( statusMessage_.empty() )
00066       statusMessage_ = m;
00067   }
00068   
00069   
00070   void StateMachineMonitorCollection::clearStatusMessage()
00071   {
00072     boost::mutex::scoped_lock sl( stateMutex_ );
00073     statusMessage_.clear();
00074   }
00075   
00076   
00077   bool StateMachineMonitorCollection::statusMessage( std::string& m ) const
00078   {
00079     boost::mutex::scoped_lock sl( stateMutex_ );
00080     m = statusMessage_;
00081     return ( ! statusMessage_.empty() );
00082   }
00083   
00084   
00085   std::string StateMachineMonitorCollection::innerStateName() const
00086   {
00087     boost::mutex::scoped_lock sl( stateMutex_ );
00088     TransitionRecord tr = history_.back();
00089     return tr.stateName();;
00090   }
00091   
00092   
00093   void StateMachineMonitorCollection::do_calculateStatistics()
00094   {
00095     // nothing to do
00096   }
00097   
00098   
00099   void StateMachineMonitorCollection::do_reset()
00100   {
00101     // we shall not reset the state name
00102     boost::mutex::scoped_lock sl( stateMutex_ );
00103     history_.clear();
00104   }
00105   
00106   
00107   void StateMachineMonitorCollection::do_appendInfoSpaceItems
00108   (
00109     InfoSpaceItems& infoSpaceItems
00110   )
00111   {
00112     infoSpaceItems.push_back(std::make_pair("stateName", &stateName_));
00113   }
00114   
00115   
00116   void StateMachineMonitorCollection::do_updateInfoSpaceItems()
00117   {
00118     boost::mutex::scoped_lock sl( stateMutex_ );
00119     
00120     stateName_ = static_cast<xdata::String>( externallyVisibleState_ );
00121   }
00122   
00123 } // namespace stor
00124