INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

substatus.h

00001 /*
00002  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
00003  *               http://gearbox.sf.net/
00004  * Copyright (c) 2004-2010 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This distribution is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef GBXUTILACFR_SUBSYSTEM_STATUS_H
00012 #define GBXUTILACFR_SUBSYSTEM_STATUS_H
00013 
00014 #if defined (WIN32)
00015     #if defined (GBXUTILACFR_STATIC)
00016         #define GBXUTILACFR_EXPORT
00017     #elif defined (GBXUTILACFR_EXPORTS)
00018         #define GBXUTILACFR_EXPORT       __declspec (dllexport)
00019     #else
00020         #define GBXUTILACFR_EXPORT       __declspec (dllimport)
00021     #endif
00022 #else
00023     #define GBXUTILACFR_EXPORT
00024 #endif
00025 
00026 #include <gbxutilacfr/status.h>
00027 
00028 namespace gbxutilacfr {
00029 
00039 class GBXUTILACFR_EXPORT SubStatus
00040 {
00041 
00042 public:
00045     SubStatus( Status& status, const std::string& subsysName, double maxHeartbeatIntervalSec=-1.0 ) :
00046         status_(status),
00047         subsysName_(subsysName)
00048     {
00049         status_.addSubsystem( subsysName_, maxHeartbeatIntervalSec );
00050     };
00051 
00053     ~SubStatus();
00054 
00055     //
00056     // set expectations about ourselves
00057     //
00058 
00060     void setMaxHeartbeatInterval( double interval ) { status_.setMaxHeartbeatInterval( subsysName_, interval ); };
00061 
00063     void setSubsystemType( SubsystemType type ) { status_.setSubsystemType( subsysName_, type ); };
00064 
00065     //
00066     // set health
00067     //
00068 
00070     void heartbeat() { status_.heartbeat( subsysName_ ); };
00071 
00073     void message( const std::string& message ) { status_.message( subsysName_, message ); };
00074 
00076     void ok( const std::string& message="" ) { status_.ok( subsysName_, message ); };
00077 
00079     void warning( const std::string& message ) { status_.warning( subsysName_, message ); };
00080 
00082     void critical( const std::string& message ) { status_.critical( subsysName_, message ); };
00083 
00084     //
00085     // Set state machine states
00086     //
00087 
00089     void initialising() { status_.initialising( subsysName_ ); };
00090 
00092     void working() { status_.working( subsysName_ ); };
00093 
00095     void finalising() { status_.finalising( subsysName_ ); };
00096 
00098     void fault( const std::string& message ) { status_.fault( subsysName_, message ); };
00099 
00101     Status& status() { return status_; };
00102 
00104     std::string name() const { return subsysName_; };
00105 
00106 private:
00107 
00108     // Make this uncopyable
00109     SubStatus(const SubStatus&);
00110     void operator=(const SubStatus&);
00111 
00112     Status& status_;
00113     std::string subsysName_;
00114 };
00115 
00116 } // namespace
00117 
00118 #endif
 

Generated for GearBox by  doxygen 1.4.5