Homepage Demos Overview Downloads Tutorials Reference
Credits

BehaviorBase Class Reference

#include <BehaviorBase.h>

Inheritance diagram for BehaviorBase:

Inheritance graph
[legend]
List of all members.

Detailed Description

The basis from which all other Behaviors should inherit.

Makes use of ReferenceCounter so that behaviors can automatically delete themselves if wanted.

Make sure your own DoStart and DoStop call BehaviorBase::DoStart (or Stop) to allow the auto-deletion from reference counting... otherwise you'll get memory leaks if you rely on the reference counting.

For an empty behavior boilerplate file to help you get started quickly, try Tekkotsu/docs/behavior_header.h:

But it would probably still be a good idea to go through the "First Behavior" tutorial to get a better idea of what's going on.

Definition at line 25 of file BehaviorBase.h.

Public Member Functions

virtual ~BehaviorBase ()
 destructor - if is active when deleted, will call DoStop() first
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 &)
 By defining here, allows you to get away with not supplying a processEvent() function for the EventListener interface. By default, does nothing.
virtual std::string getName () const
 Identifies the behavior in menus and such.
virtual void setName (const std::string &name)
 Allows dynamic renaming of behaviors.
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).
virtual std::string getClassName () const
 Returns the name of the class of this behavior (aka its type).
virtual bool isActive () const
 Returns true if the behavior is currently running.

Static Public Member Functions

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 const std::set< BehaviorBase * > & getRegistry ()
 Allows read-only access to the set of currently instantiated behaviors.

Protected Member Functions

 BehaviorBase () __attribute__((deprecated))
 deprecated, behavior constructors should take a name argument (which by default should be the name of the type of the class)
 BehaviorBase (const std::string &name)
 constructor, name is used as both instance name and class name
 BehaviorBase (const std::string &classname, const std::string &instancename)
 constructor, allows different initial values for class name and instance name
 BehaviorBase (const BehaviorBase &b)
 copy constructor; assumes subclass handles copying approriately - i.e. if b is active, the copy will be as well, even though DoStart was never called..
BehaviorBaseoperator= (const BehaviorBase &b)
 assignment operator; assumes subclass handles assignment appropriately - i.e. if b is active, the copy will be as well, even though DoStart was never called..

Protected Attributes

bool started
 true when the behavior is active
std::string instanceName
 holds the name of this instance of behavior
const std::string className
 holds the type of the subclass of this behavior as a string

Static Protected Attributes

static std::set< BehaviorBase * > registry
 allows us to keep track of all the current behaviors


Constructor & Destructor Documentation

BehaviorBase::~BehaviorBase  )  [virtual]
 

destructor - if is active when deleted, will call DoStop() first

Definition at line 44 of file BehaviorBase.cc.

BehaviorBase::BehaviorBase  )  [protected]
 

deprecated, behavior constructors should take a name argument (which by default should be the name of the type of the class)

Deprecated:
, behavior constructors should take a name argument (which by default should be the name of the type of the class)

Definition at line 6 of file BehaviorBase.cc.

BehaviorBase::BehaviorBase const std::string &  name  )  [explicit, protected]
 

constructor, name is used as both instance name and class name

Definition at line 13 of file BehaviorBase.cc.

BehaviorBase::BehaviorBase const std::string &  classname,
const std::string &  instancename
[protected]
 

constructor, allows different initial values for class name and instance name

Definition at line 20 of file BehaviorBase.cc.

BehaviorBase::BehaviorBase const BehaviorBase b  )  [protected]
 

copy constructor; assumes subclass handles copying approriately - i.e. if b is active, the copy will be as well, even though DoStart was never called..

Definition at line 28 of file BehaviorBase.cc.


Member Function Documentation

void BehaviorBase::DoStart  )  [virtual]
 

By default, merely adds to the reference counter (through AddReference()); Note you should still call this from your overriding methods.

Reimplemented in Controller, FreeMemReportControl, AlanBehavior, ASCIIVisionBehavior, AutoGetupBehavior, BanditMachine, BanditMachine::PressNode, BanditMachine::DecideNode, BanditMachine::WaitNode, BatteryMonitorBehavior, CameraBehavior, ChaseBallBehavior, CrashTestBehavior, DriveMeBehavior, ExploreMachine, FollowHeadBehavior, FreezeTestBehavior, GroundPlaneBehavior, HeadLevelBehavior, HelloWorldBehavior, KinematicSampleBehavior, KinematicSampleBehavior2, LookForSoundBehavior, MCRepeater, MotionStressTestBehavior, PaceTargetsMachine, RelaxBehavior, SimpleChaseBallBehavior, SoundTestBehavior, StareAtBallBehavior, StareAtPawBehavior, StareAtPawBehavior2, ToggleHeadLightBehavior, WallTestBehavior, WorldStateVelDaemon, Aibo3DControllerBehavior, EStopControllerBehavior, HeadPointControllerBehavior, MicrophoneServer, RawCamBehavior, SegCamBehavior, SpeakerServer, SpiderMachineBehavior, ViewWMVarsBehavior, WalkControllerBehavior, WMMonitorBehavior, WorldStateSerializerBehavior, GroupNode, HeadPointerNode, LedNode, OutputNode, PlayMotionSequenceNode< SIZE >, SoundNode, TailWagNode, WalkNode, WalkToTargetNode, StateNode, CompareTrans< T >, CompletionTrans, EventTrans, LostTargetTrans, NullTrans, SmoothCompareTrans< T >, TimeOutTrans, VisualTargetCloseTrans, VisualTargetTrans, and EventGeneratorBase.

Definition at line 53 of file BehaviorBase.cc.

Referenced by BehaviorActivatorControl::activate(), BehaviorSwitchControl< B, Al >::BehaviorSwitchControl(), WorldStateVelDaemon::DoStart(), WorldStateSerializerBehavior::DoStart(), WMMonitorBehavior::DoStart(), WallTestBehavior::DoStart(), WalkControllerBehavior::DoStart(), VisualTargetTrans::DoStart(), VisualTargetCloseTrans::DoStart(), ViewWMVarsBehavior::DoStart(), ToggleHeadLightBehavior::DoStart(), TimeOutTrans::DoStart(), StateNode::DoStart(), StareAtPawBehavior2::DoStart(), StareAtPawBehavior::DoStart(), StareAtBallBehavior::DoStart(), SpiderMachineBehavior::DoStart(), SpeakerServer::DoStart(), SoundTestBehavior::DoStart(), SimpleChaseBallBehavior::DoStart(), SegCamBehavior::DoStart(), RelaxBehavior::DoStart(), RawCamBehavior::DoStart(), NullTrans::DoStart(), MotionStressTestBehavior::DoStart(), MicrophoneServer::DoStart(), MCRepeater::DoStart(), LookForSoundBehavior::DoStart(), KinematicSampleBehavior2::DoStart(), KinematicSampleBehavior::DoStart(), HelloWorldBehavior::DoStart(), HeadPointControllerBehavior::DoStart(), HeadLevelBehavior::DoStart(), GroundPlaneBehavior::DoStart(), FreezeTestBehavior::DoStart(), FreeMemReportControl::DoStart(), FollowHeadBehavior::DoStart(), EventTrans::DoStart(), EventGeneratorBase::DoStart(), EStopControllerBehavior::DoStart(), DriveMeBehavior::DoStart(), CrashTestBehavior::DoStart(), Controller::DoStart(), CompletionTrans::DoStart(), CompareTrans< T >::DoStart(), ChaseBallBehavior::DoStart(), CameraBehavior::DoStart(), BatteryMonitorBehavior::DoStart(), AutoGetupBehavior::DoStart(), ASCIIVisionBehavior::DoStart(), AlanBehavior::DoStart(), Aibo3DControllerBehavior::DoStart(), BehaviorSwitchControl< B, Al >::startmine(), and BehaviorSwitchControlBase::startmine().

void BehaviorBase::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 in Controller, FreeMemReportControl, AlanBehavior, ASCIIVisionBehavior, AutoGetupBehavior, BanditMachine, BanditMachine::PressNode, BanditMachine::WaitNode, BatteryMonitorBehavior, CameraBehavior, ChaseBallBehavior, DriveMeBehavior, ExploreMachine, FollowHeadBehavior, GroundPlaneBehavior, HeadLevelBehavior, KinematicSampleBehavior, KinematicSampleBehavior2, LookForSoundBehavior, MCRepeater, MotionStressTestBehavior, RelaxBehavior, SimpleChaseBallBehavior, SoundTestBehavior, StareAtBallBehavior, StareAtPawBehavior, StareAtPawBehavior2, ToggleHeadLightBehavior, WallTestBehavior, WorldStateVelDaemon, Aibo3DControllerBehavior, EStopControllerBehavior, HeadPointControllerBehavior, MicrophoneServer, RawCamBehavior, SegCamBehavior, SpeakerServer, SpiderMachineBehavior, ViewWMVarsBehavior, WalkControllerBehavior, WMMonitorBehavior, WorldStateSerializerBehavior, HeadPointerNode, LedNode, PlayMotionSequenceNode< SIZE >, SoundNode, TailWagNode, WalkNode, WalkToTargetNode, StateNode, CompareTrans< T >, CompletionTrans, EventTrans, NullTrans, TimeOutTrans, VisualTargetCloseTrans, VisualTargetTrans, and EventGeneratorBase.

Definition at line 62 of file BehaviorBase.cc.

Referenced by BehaviorActivatorControl::activate(), BehaviorSwitchControl< B, Al >::BehaviorSwitchControl(), HelloWorldBehavior::DoStart(), WorldStateVelDaemon::DoStop(), WorldStateSerializerBehavior::DoStop(), WMMonitorBehavior::DoStop(), WallTestBehavior::DoStop(), WalkControllerBehavior::DoStop(), VisualTargetTrans::DoStop(), VisualTargetCloseTrans::DoStop(), ViewWMVarsBehavior::DoStop(), TimeOutTrans::DoStop(), StateNode::DoStop(), StareAtPawBehavior2::DoStop(), StareAtPawBehavior::DoStop(), StareAtBallBehavior::DoStop(), SpiderMachineBehavior::DoStop(), SpeakerServer::DoStop(), SoundTestBehavior::DoStop(), SimpleChaseBallBehavior::DoStop(), SegCamBehavior::DoStop(), RelaxBehavior::DoStop(), RawCamBehavior::DoStop(), NullTrans::DoStop(), MotionStressTestBehavior::DoStop(), MicrophoneServer::DoStop(), MCRepeater::DoStop(), LookForSoundBehavior::DoStop(), KinematicSampleBehavior2::DoStop(), KinematicSampleBehavior::DoStop(), HeadPointControllerBehavior::DoStop(), HeadLevelBehavior::DoStop(), GroundPlaneBehavior::DoStop(), FreeMemReportControl::DoStop(), FollowHeadBehavior::DoStop(), EventTrans::DoStop(), EventGeneratorBase::DoStop(), EStopControllerBehavior::DoStop(), DriveMeBehavior::DoStop(), Controller::DoStop(), CompletionTrans::DoStop(), CompareTrans< T >::DoStop(), ChaseBallBehavior::DoStop(), CameraBehavior::DoStop(), BatteryMonitorBehavior::DoStop(), AutoGetupBehavior::DoStop(), ASCIIVisionBehavior::DoStop(), AlanBehavior::DoStop(), Aibo3DControllerBehavior::DoStop(), BehaviorSwitchControl< B, Al >::stopother(), BehaviorSwitchControlBase::stopother(), ~BehaviorBase(), and BehaviorSwitchControlBase::BehaviorGroup::~BehaviorGroup().

static std::string BehaviorBase::getClassDescription  )  [inline, static]
 

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

If you do override this, also consider overriding getDescription() to return it

Reimplemented in Controller, AlanBehavior, ASCIIVisionBehavior, AutoGetupBehavior, BanditMachine, BatteryMonitorBehavior, CameraBehavior, ChaseBallBehavior, CrashTestBehavior, DriveMeBehavior, FollowHeadBehavior, FreezeTestBehavior, GroundPlaneBehavior, HeadLevelBehavior, HelloWorldBehavior, KinematicSampleBehavior, KinematicSampleBehavior2, LookForSoundBehavior, MCRepeater, MotionStressTestBehavior, RelaxBehavior, SoundTestBehavior, StareAtBallBehavior, StareAtPawBehavior, StareAtPawBehavior2, ToggleHeadLightBehavior, WallTestBehavior, WorldStateVelDaemon, Aibo3DControllerBehavior, EStopControllerBehavior, HeadPointControllerBehavior, RawCamBehavior, SegCamBehavior, SpiderMachineBehavior, ViewWMVarsBehavior, WalkControllerBehavior, WMMonitorBehavior, WorldStateSerializerBehavior, WalkToTargetNode, BallDetectionGenerator, CDTGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator.

Definition at line 72 of file BehaviorBase.h.

Referenced by getDescription().

virtual std::string BehaviorBase::getClassName  )  const [inline, virtual]
 

Returns the name of the class of this behavior (aka its type).

Note that this isn't static to avoid the problems we found with getDescription/getClassDescription. So instead we wind up wasting some memory in each instance of the class to store the className, but at least it will work the way you expect.

Definition at line 68 of file BehaviorBase.h.

Referenced by BehaviorSwitchControlBase::getDescription().

virtual std::string BehaviorBase::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 in Controller, AlanBehavior, ASCIIVisionBehavior, AutoGetupBehavior, BanditMachine, BatteryMonitorBehavior, CameraBehavior, ChaseBallBehavior, CrashTestBehavior, DriveMeBehavior, FollowHeadBehavior, FreezeTestBehavior, GroundPlaneBehavior, HeadLevelBehavior, HelloWorldBehavior, KinematicSampleBehavior, KinematicSampleBehavior2, LookForSoundBehavior, MCRepeater, MotionStressTestBehavior, RelaxBehavior, SoundTestBehavior, StareAtBallBehavior, StareAtPawBehavior, StareAtPawBehavior2, ToggleHeadLightBehavior, WallTestBehavior, WorldStateVelDaemon, Aibo3DControllerBehavior, EStopControllerBehavior, HeadPointControllerBehavior, RawCamBehavior, SegCamBehavior, SpiderMachineBehavior, ViewWMVarsBehavior, WalkControllerBehavior, WMMonitorBehavior, WorldStateSerializerBehavior, and WalkToTargetNode.

Definition at line 58 of file BehaviorBase.h.

Referenced by BehaviorSwitchControl< B, Al >::getDescription(), and BehaviorSwitchControlBase::getDescription().

virtual std::string BehaviorBase::getName  )  const [inline, virtual]
 

Identifies the behavior in menus and such.

Reimplemented in FreeMemReportControl, and Transition.

Definition at line 40 of file BehaviorBase.h.

Referenced by BallDetectionGenerator::createEvent(), StateNode::DoStart(), StateNode::DoStop(), SpiderMachineBehavior::find(), getDescription(), BehaviorSwitchControlBase::getName(), TailWagNode::processEvent(), SpiderMachineBehavior::processEvent(), SoundNode::processEvent(), PlayMotionSequenceNode< SIZE >::processEvent(), LedNode::processEvent(), HeadPointerNode::processEvent(), SpiderMachineBehavior::runCommand(), PaceTargetsMachine::setup(), ExploreMachine::setup(), and SpiderMachineBehavior::spider().

static const std::set<BehaviorBase*>& BehaviorBase::getRegistry  )  [inline, static]
 

Allows read-only access to the set of currently instantiated behaviors.

Not all of these behaviors are necessarily active, this is everything that has been allocated and not yet deallocated

Definition at line 79 of file BehaviorBase.h.

Referenced by BehaviorReportControl::activate().

virtual bool BehaviorBase::isActive  )  const [inline, virtual]
 

Returns true if the behavior is currently running.

Definition at line 75 of file BehaviorBase.h.

Referenced by BehaviorActivatorControl::activate(), BehaviorSwitchControl< B, Al >::BehaviorSwitchControl(), RandomTrans::fire(), FreeMemReportControl::getName(), BehaviorSwitchControlBase::getName(), BehaviorSwitchControlBase::isRunning(), PlayMotionSequenceNode< SIZE >::setFile(), BehaviorSwitchControl< B, Al >::startmine(), BehaviorSwitchControl< B, Al >::stopother(), BehaviorSwitchControlBase::stopother(), FollowHeadBehavior::~FollowHeadBehavior(), and StateNode::~StateNode().

BehaviorBase & BehaviorBase::operator= const BehaviorBase b  )  [protected]
 

assignment operator; assumes subclass handles assignment appropriately - i.e. if b is active, the copy will be as well, even though DoStart was never called..

Definition at line 36 of file BehaviorBase.cc.

Referenced by Transition::operator=().

virtual void BehaviorBase::processEvent const EventBase  )  [inline, virtual]
 

By defining here, allows you to get away with not supplying a processEvent() function for the EventListener interface. By default, does nothing.

Implements EventListener.

Reimplemented in Controller, FreeMemReportControl, AlanBehavior, ASCIIVisionBehavior, AutoGetupBehavior, BanditMachine::WaitNode, BatteryMonitorBehavior, CameraBehavior, ChaseBallBehavior, DriveMeBehavior, ExploreMachine, FollowHeadBehavior, GroundPlaneBehavior, HeadLevelBehavior, KinematicSampleBehavior, KinematicSampleBehavior2, LookForSoundBehavior, MCRepeater, MotionStressTestBehavior, SimpleChaseBallBehavior, SoundTestBehavior, StareAtBallBehavior, StareAtPawBehavior, StareAtPawBehavior2, WallTestBehavior, WorldStateVelDaemon, EStopControllerBehavior, HeadPointControllerBehavior, MicrophoneServer, RawCamBehavior, SegCamBehavior, SpiderMachineBehavior, WalkControllerBehavior, WMMonitorBehavior, WorldStateSerializerBehavior, HeadPointerNode, LedNode, PlayMotionSequenceNode< SIZE >, SoundNode, TailWagNode, WalkToTargetNode, CompareTrans< T >, CompletionTrans, EventTrans, LostTargetTrans, NullTrans, SmoothCompareTrans< T >, TimeOutTrans, VisualTargetCloseTrans, VisualTargetTrans, EventGeneratorBase, BallDetectionGenerator, CDTGenerator, FilterBankGenerator, InterleavedYUVGenerator, JPEGGenerator, RawCameraGenerator, RegionGenerator, RLEGenerator, and SegmentedColorGenerator.

Definition at line 37 of file BehaviorBase.h.

virtual void BehaviorBase::setName const std::string &  name  )  [inline, virtual]
 

Allows dynamic renaming of behaviors.

Definition at line 43 of file BehaviorBase.h.

Referenced by PaceTargetsMachine::setup(), and BehaviorSwitchControl< B, Al >::startmine().


Member Data Documentation

const std::string BehaviorBase::className [protected]
 

holds the type of the subclass of this behavior as a string

Definition at line 107 of file BehaviorBase.h.

Referenced by getClassName().

std::string BehaviorBase::instanceName [protected]
 

holds the name of this instance of behavior

Definition at line 106 of file BehaviorBase.h.

Referenced by getName(), operator=(), and setName().

std::set< BehaviorBase * > BehaviorBase::registry [static, protected]
 

allows us to keep track of all the current behaviors

Definition at line 3 of file BehaviorBase.cc.

Referenced by BehaviorBase(), getRegistry(), and ~BehaviorBase().

bool BehaviorBase::started [protected]
 

true when the behavior is active

Definition at line 105 of file BehaviorBase.h.

Referenced by DoStart(), DoStop(), isActive(), operator=(), and ~BehaviorBase().


The documentation for this class was generated from the following files:

Tekkotsu v2.2.2
Generated Tue Jan 4 15:45:21 2005 by Doxygen 1.4.0