SpiderMachineBehavior Class Reference#include <SpiderMachineBehavior.h>
Inheritance diagram for SpiderMachineBehavior:
[legend]List of all members.
Detailed Description
When active and connected over network socket, outputs structure of requested state machine(s).
The protocol is:
- '
list ' - send list of all instantiated StateNodes - '
spider name' - spider the current structure of StateNode named name - '
listen name' - send updates regarding the activation status of name and its subnodes; you can specify a state which is not yet running - '
ignore name' - cancels a previous listen command - '
clear ' - cancels all previous listen commands; should be called at the beginning or end of each connection, preferably both
Each of those commands should be terminated with a newline - i.e. one command per line
After a list command, the first line will be the number of StateNodes, followed by that number of lines, one StateNode name per line.
After a spider command, an XML description of the model will be sent. If no matching StateNode is found, an warning will be displayed on serr, and an empty model ("<model></model>") returned over the network connection.
All other commands give no direct response - listen can be executed before the specified StateNode is yet running, and ignore doesn't care whether or not the specified StateNode was actually being listened for.
The format of the model is: <!DOCTYPE model [
<!ELEMENT model (state*, transition*)>
<!ELEMENT state (state*, transition*)>
<!ELEMENT transition (source+, dest+)>
<!ELEMENT source (#PCDATA)>
<!ELEMENT dest (#PCDATA)>
<!ATTLIST state id CDATA #REQUIRED>
<!ATTLIST state class CDATA #REQUIRED>
<!ATTLIST transition id CDATA #REQUIRED>
<!ATTLIST transition class CDATA #REQUIRED>
]>
The format of status updates following a listen command is: <!DOCTYPE event [
<!ELEMENT event (fire*, statestart*, statestop*)>
<!ELEMENT fire (EMPTY)>
<!ELEMENT statestart (EMPTY)>
<!ELEMENT statestop (EMPTY)>
<!ATTLIST fire id CDATA #REQUIRED>
<!ATTLIST fire time CDATA #REQUIRED>
<!ATTLIST statestart id CDATA #REQUIRED>
<!ATTLIST statestart time CDATA #REQUIRED>
<!ATTLIST statestop id CDATA #REQUIRED>
<!ATTLIST statestop time CDATA #REQUIRED>
]>
Definition at line 67 of file SpiderMachineBehavior.h.
|
Public Member Functions |
| SpiderMachineBehavior () |
| constructor
|
virtual void | DoStart () |
| By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.
|
virtual void | DoStop () |
| By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).
|
virtual void | processEvent (const EventBase &e) |
| By defining here, allows you to get away with not supplying a processEvent() function for the EventListener interface. By default, does nothing.
|
void | spider (const StateNode *n, unsigned int depth=0) |
| dumps all of the transitions and subnodes of a given statenode
|
bool | isListening (const StateNode *n) |
| returns true iff n or one of its parents is found in listen
|
virtual std::string | getDescription () const |
| Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).
|
void | runCommand (const std::string &s) |
| parses commands sent from callback()
|
Static Public Member Functions |
static int | callback (char *buf, int bytes) |
| called by wireless when there's new data
|
static std::string | getClassDescription () |
| Gives a short description of what this class of behaviors does... you should override this (but don't have to).
|
Static Public Attributes |
static SpiderMachineBehavior * | theOne = NULL |
| Points to the one SpiderMachineBehavior object that the input command stream is talking to.
|
static unsigned int | port = 10081 |
| the port to listen on (10081 by default)
|
Protected Types |
typedef std::set< BehaviorBase * > | registry_t |
| the type of the behavior registry (BehaviorBase::registry)
|
typedef std::multiset< const
StateNode * > | expected_t |
| the type of expected
|
typedef std::set< std::string > | listen_t |
| the type of listen
|
typedef std::queue< EventBase > | queuedEvents_t |
| the type of queuedEvents
|
Protected Member Functions |
void | indent (unsigned int level) |
| just to prettify the data sent out - probably should make this a null-op to save bandwidth after debugging is done
|
const StateNode * | find (const std::string &name) |
| searches currently instantiated StateNodes to find the one named name
|
Protected Attributes |
Socket * | cmdsock |
| the socket for communication
|
expected_t | expected |
| a set of behaviors which are involved with an impending transition - their next stateMachineEGID event should be ignored
|
listen_t | listen |
| a set of state machine names which should have their subnodes monitored
|
queuedEvents_t | queuedEvents |
| used if a transition causes other transitions, those transitions need to be remembered
|
Private Member Functions |
| SpiderMachineBehavior (const SpiderMachineBehavior &) |
| don't call
|
SpiderMachineBehavior | operator= (const SpiderMachineBehavior &) |
| don't call
|
Member Typedef Documentation
Constructor & Destructor Documentation
SpiderMachineBehavior::SpiderMachineBehavior |
( |
|
) |
[inline] |
|
Member Function Documentation
int SpiderMachineBehavior::callback |
( |
char * |
buf, |
|
|
int |
bytes |
|
) |
[static] |
|
void SpiderMachineBehavior::DoStart |
( |
|
) |
[virtual] |
|
void SpiderMachineBehavior::DoStop |
( |
|
) |
[virtual] |
|
|
By default, subtracts from the reference counter (RemoveReference()), and thus may deletex if zero; Don't forget to still call this when you override this; Warning: call this at the end of your DoStop(), not beginning (it might delete this ).
Reimplemented from BehaviorBase.
Definition at line 21 of file SpiderMachineBehavior.cc. |
const StateNode * SpiderMachineBehavior::find |
( |
const std::string & |
name |
) |
[protected] |
|
static std::string SpiderMachineBehavior::getClassDescription |
( |
|
) |
[inline, static] |
|
virtual std::string SpiderMachineBehavior::getDescription |
( |
|
) |
const [inline, virtual] |
|
|
Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).
By default simply returns getName(), because any calls from a BehaviorBase function to getClassDescription() are going to call BehaviorBase::getClassDescription(), not ~YourSubClass~getClassDescription(), because static functions can't be virtual in C++ (doh!)
This means that getDescription called on a pointer to a BehaviorBase of unknown subtype would always return an empty string, which is pretty useless. So instead we return the name in this situation. If you want getDescription to return getClassDescription, you'll have to override it in your subclass to do so.
Reimplemented from BehaviorBase.
Definition at line 95 of file SpiderMachineBehavior.h. |
void SpiderMachineBehavior::indent |
( |
unsigned int |
level |
) |
[protected] |
|
bool SpiderMachineBehavior::isListening |
( |
const StateNode * |
n |
) |
|
|
void SpiderMachineBehavior::processEvent |
( |
const EventBase & |
e |
) |
[virtual] |
|
void SpiderMachineBehavior::runCommand |
( |
const std::string & |
s |
) |
|
|
void SpiderMachineBehavior::spider |
( |
const StateNode * |
n, |
|
|
unsigned int |
depth = 0 |
|
) |
|
|
Member Data Documentation
|
Points to the one SpiderMachineBehavior object that the input command stream is talking to.
A kludge. Dunno how you're gonna make sure you're not using this uninitialized.
Definition at line 71 of file SpiderMachineBehavior.h.
Referenced by DoStart(), and DoStop(). |
The documentation for this class was generated from the following files:
|