|
From: <rus...@us...> - 2008-10-28 09:37:15
|
Revision: 350
http://gearbox.svn.sourceforge.net/gearbox/?rev=350&view=rev
Author: russo2503v
Date: 2008-10-28 09:32:51 +0000 (Tue, 28 Oct 2008)
Log Message:
-----------
added constructor, another toString(), and docco
Modified Paths:
--------------
gearbox/trunk/src/gbxutilacfr/status.cpp
gearbox/trunk/src/gbxutilacfr/status.h
Modified: gearbox/trunk/src/gbxutilacfr/status.cpp
===================================================================
--- gearbox/trunk/src/gbxutilacfr/status.cpp 2008-10-28 00:09:36 UTC (rev 349)
+++ gearbox/trunk/src/gbxutilacfr/status.cpp 2008-10-28 09:32:51 UTC (rev 350)
@@ -9,6 +9,7 @@
*/
#include "status.h"
+#include <sstream>
namespace gbxutilacfr {
@@ -46,4 +47,12 @@
return "Stalled";
}
+std::string toString( const SubsystemStatus& status )
+{
+ std::stringstream ss;
+ ss << "state="<<toString(status.state)<<" health="<<toString(status.health)
+ << " msg='"<<status.message<<"' since hearbeat="<<status.sinceHeartbeat;
+ return ss.str();
+}
+
} // namespace
Modified: gearbox/trunk/src/gbxutilacfr/status.h
===================================================================
--- gearbox/trunk/src/gbxutilacfr/status.h 2008-10-28 00:09:36 UTC (rev 349)
+++ gearbox/trunk/src/gbxutilacfr/status.h 2008-10-28 09:32:51 UTC (rev 350)
@@ -53,6 +53,13 @@
//! Status for a single subsystem
struct SubsystemStatus
{
+ //! Constructor.
+ SubsystemStatus( SubsystemState s=SubsystemIdle, SubsystemHealth h=SubsystemOk, const std::string& msg="", double beat=0.0 ) :
+ state(s),
+ health(h),
+ message(msg),
+ sinceHeartbeat(beat) {};
+
//! Current state in the subsystem's state machine. I.e. what is the subsystem doing?
SubsystemState state;
@@ -65,9 +72,12 @@
//! Ratio of time since last heartbeat to maximum expected time between heartbeats.
//! For example, sinceHeartbeat=0.5 means that half of normally expected interval between heartbeats
//! has elapsed.
- float sinceHeartbeat;
+ double sinceHeartbeat;
};
+//! Returns human-readable string with subsystem status information.
+std::string toString( const SubsystemStatus& status );
+
/*!
@brief Local interface to component status.
@@ -156,7 +166,11 @@
//! Sets state of the subsystem to Initialising. Note that empty message is assumed if none is supplied.
//! Throws gbxutilacfr::Exception if the subsystem does not exist.
virtual void initialising( const std::string& subsystem, const std::string& message="" )=0;
+ //! Sets state of the subsystem to Working. Note that empty message is assumed if none is supplied.
+ //! Throws gbxutilacfr::Exception if the subsystem does not exist.
virtual void working( const std::string& subsystem, const std::string& message="" )=0;
+ //! Sets state of the subsystem to Finalising. Note that empty message is assumed if none is supplied.
+ //! Throws gbxutilacfr::Exception if the subsystem does not exist.
virtual void finalising( const std::string& subsystem, const std::string& message="" )=0;
//
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|