Files

135 lines
3.3 KiB
C++

/**
* @file include/ActivMiddleware/ActivFramework/IProcess.h
*
* @brief Header file for process interface class.
*/
#if (!defined ACTIV_FRAMEWORK_IPROCESS_H)
#define ACTIV_FRAMEWORK_IPROCESS_H
#include "ActivMiddleware/ActivFramework/External.h"
#include "ActivMiddleware/ActivBase/MessageValidator.h"
#include "ActivMiddleware/ActivBase/MessageBuilder.h"
#include "ActivMiddleware/ActivBase/Process.h"
#include "ActivMiddleware/ActivBase/Timeout.h"
/**
* @brief List of process states.
*/
#define ACTIV_IPROCESS_STATE_LIST(d) \
d(STATE_INITIALIZING, "initializing") \
d(STATE_RUNNING, "running") \
d(STATE_SHUTTING_DOWN, "shutting down") \
d(STATE_EXITED, "exited") \
d(STATE_DEAD, "dead")
//! Activ namespace.
namespace Activ
{
class ISystem;
class Uuid;
// ---------------------------------------------------------------------------------------------------------------------------------
/**
* @brief Process interface class.
*/
class IProcess : private Boost::noncopyable
{
public:
typedef Process::Id OsProcessId;
//! @brief Process states.
enum State
{
ACTIV_IPROCESS_STATE_LIST(ACTIV_DECLARE_ELEMENT_1_WITH_COMMA)
NUM_STATES
};
//! Process stats.
class Stats
{
public:
ProcessId m_id; ///< System wide id of the process.
OsProcessId m_osId; ///< OS wide id if the process.
String m_name; ///< Name of the process in the system.
String m_version; ///< Process version string.
String m_type; ///< Process type string.
String m_userContext; ///< Arbitrary user context string.
State m_state; ///< State of the process.
};
//! Destructor.
virtual ~IProcess() = 0;
//! Get the system unique process id for this process.
virtual ProcessId GetId() const = 0;
//! Get the os process id for this process.
virtual OsProcessId GetOsId() const = 0;
//! @brief Get the name of this process.
virtual const String &GetName() const = 0;
//! Get the type of this process.
virtual const String &GetType() const = 0;
//! Get the user context for this process.
virtual const String &GetUserContext() const = 0;
//! Get UUID of this process.
virtual const Uuid &GetUuid() const = 0;
//! Get the system that created the process.
virtual ISystem *GetSystem() const = 0;
/**
* @brief Get process stats.
*
* @param stats reference to a Stats object.
*/
virtual void GetStats(Stats &stats) const = 0;
//! Get the current state of the process.
virtual State GetState() const = 0;
/**
* @brief Set the state of the process.
*
* @param state new state.
*/
virtual void SetState(const State state) = 0;
/**
* @brief Wait for the state of the process to be a given value.
*
* @param state to wait for.
* @param timeout how long to wait.
*
* @retval STATUS_CODE_SUCCESS
* @retval STATUS_CODE_TIMEOUT
*/
virtual StatusCode WaitForState(const State state, Timeout &timeout = Timeout::GetInfinite()) = 0;
/**
* @brief Convert process state to string.
*
* @param state state to convert.
*
* @return string form of system state.
*/
ACTIV_FRAMEWORK_API
static String StateToString(const State state);
};
// ---------------------------------------------------------------------------------------------------------------------------------
inline IProcess::~IProcess()
{
}
} // namespace Activ
#endif // (!defined ACTIV_FRAMEWORK_IPROCESS_H)