RunState

Name

RunState -- Encapsulate important state of the software.

Synopsis


#include <RunState.h>
         
 class RunState {
  State m_state;
  uint32_t m_runNumber;
  uint32_t m_timeOffset;
  char* m_pTitle;

  static RunState* getInstance();
  const std::string stateName();
  static std::string stateName(State state);
}

Description

This is essentially a singleton structure that encapsulates the state of the run. See Types and Public data for a description of the data elements of the struct. See Public Member functions for the methods. Note that since this is a singleton, construction is private. You must use the getInstance() method to obtain a pointer to the one and only instance of the object.

Public member functions

static RunState* getInstance();

Returns a pointer to the one and only instance of this class. If no instance exists yet, it is created.

const std::string stateName();

Returns a text string that describes the current state of the run. This is a textual equivalent of the m_state member variable.

static std::string stateName(State state);

Given a state returns the textual equivalent of that state.

Types and public data

Since member data can be set and read, getters and setter methods would be overkill and all data are public. The public member data are:

RunState::State m_state;

Current run state. The legal values are inactive, active and paused

uint32_t m_runNumber;

The run number of the active run or the next run (unless changed by the user), if the run is not active.

uint32_t m_timeOffset;

The nuber of seconds into the run we are. This is used by the pause/resume management to ensure that the system does not count time when the run is paused.

EXAMPLES

Example 1. Outputting the state of the run


RunState* pState = RunState::getInstance();
std::cout << " The run is currently "
          << pState->stateName
          < std::endl;