1 #ifndef CARMA_CONTROL_SYSTEMSTATEMANAGER_H
2 #define CARMA_CONTROL_SYSTEMSTATEMANAGER_H
4 #include "carma/corba/corba.h"
5 #include "carma/control/SubarrayControl.h"
7 #include "carma/monitor/MonitorSystemSelector.h"
10 #include "carma/util/PthreadMutex.h"
11 #include "carma/util/PthreadRWLock.h"
22 class MonitorContainer;
27 typedef std::set< ::carma::util::frameType > FrameSet;
28 typedef FrameSet::iterator FrameSetIter;
29 typedef FrameSet::const_iterator FrameSetConstIter;
31 typedef std::map< ::carma::monitor::tagIDType, FrameSet > TagIndex;
32 typedef TagIndex::iterator TagIndexIter;
33 typedef TagIndex::const_iterator TagIndexConstIter;
35 typedef std::set< ::carma::monitor::tagIDType > TagSet;
36 typedef TagSet::iterator TagSetIter;
37 typedef TagSet::const_iterator TagSetConstIter;
39 typedef std::map< ::carma::util::frameType, TagSet > ReverseTagIndex;
40 typedef ReverseTagIndex::iterator ReverseTagIndexIter;
41 typedef ReverseTagIndex::const_iterator ReverseTagIndexConstIter;
42 typedef ReverseTagIndex::const_reverse_iterator ReverseTagIndexConstRevIter;
48 explicit StateManager ( const ::carma::monitor::CmsSelector cmsType,
49 const ::std::string & stateDirName,
50 const bool throwOnStateDirErrors );
61 void buildIndexFromScratch(
const std::vector< std::string > & directories,
64 void restoreIndexFromFile( );
68 FrameSet getStateChangeFrames( carma::monitor::tagIDType tag )
const;
70 bool tagChangedForFrame( carma::monitor::tagIDType tag,
80 bool verifyIndexIntegrity( );
84 bool saveStateIfChanged( );
86 void restoreStateWhenUninitialized( );
90 ::std::string retrieveMostRecentFilename( )
const;
93 TagIndex::value_type parseIndexFileLine( const ::std::string & line )
const;
95 void saveIndexFilesHoldingWriteLock( )
const;
103 void indexDifferencesHoldingWriteLock (
105 ::std::string filename,
109 const TagSet & tagIdDiffs,
111 ReverseTagIndex & reverseTagIndex );
113 void cancelPendingSave(
bool deleteFile );
115 void finalizeSave( );
121 ::carma::monitor::CmsAP inputCms_;
125 ::std::string savePendingFilename_;
127 const ::std::string stateDir_;
128 const ::std::string filePrefix_;
129 const ::std::string fileSuffix_;
130 ::carma::control::SubarrayControl_var subarrayControl_;
132 struct IndexDiffRequest {
134 ::std::string newFilename;
136 ::std::string oldFilename;
139 struct IndexDiffThreadArgs {
141 ::std::deque< IndexDiffRequest > indexDiffRequestDeque;
142 TagIndex temporaryTagIndex;
143 ReverseTagIndex temporaryReverseTagIndex;
147 static void indexDiffThread( IndexDiffThreadArgs & args );
155 ReverseTagIndex reverseTagIndex_;
157 const ::std::string indexFilename_;
158 const bool throwOnStateDirError_;
A simple wrapper class that makes use of ::pthread_rwlock_t easier in a C++ world.
unsigned int frameType
Half second frames since Jan 1, 2000.
A generic monitor system container base class.
type definitions for monitor system
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Various type definitions for util classes.