NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
behaviourcontrol::BehaviourLayer Class Reference

Implements a single behaviour layer. More...

#include <behaviour_layer.h>

Inherited by behaviourcontroltest::MyL1, behaviourcontroltest::MyL2, and behaviourcontroltest::RosIL.

Classes

struct  BBasePair
 Data structure used to represent a basic inhibition pair, where behaviour A is taken to inhibit behaviour B. More...
 

Public Member Functions

 BehaviourLayer (BehaviourManager *MBase, const std::string &name=nullString, bool isInterface=false)
 Default constructor. More...
 
virtual ~BehaviourLayer ()
 Behaviour layer object destructor.
 
SensorManagergetSMBase ()
 Get function for a pointer to the base class of the child sensor manager.
 
ActuatorManagergetAMBase ()
 Get function for a pointer to the base class of the child actuator manager.
 
bool hasSM () const
 Boolean flag specifying whether this layer has a sensor manager.
 
bool hasAM () const
 Boolean flag specifying whether this layer has an actuator manager.
 
std::string getUniqueName (const BehaviourManager *MBase) const
 Returns a unique behaviour layer name. More...
 
BehaviourLayergetBasePtr ()
 Return a pointer to the underlying BehaviourLayer class object in the case of a derived behaviour layer class.
 

Public Attributes

BehaviourManager *const MBase
 Pointer to the parent behaviour manager.
 
const std::string Mname
 Human-friendly string name of the parent behaviour manager.
 
const std::string name
 Human-friendly string name of the behaviour layer.
 
const bool isInterface
 A boolean flag specifying whether the layer is an interface layer or a normal behaviour layer.
 

Static Public Attributes

static const index_t DEF_BLIST_CAPACITY = 16
 Default capacity of the list that stores the child behaviours of the layer.
 
static const index_t DEF_ILIST_CAPACITY = 32
 Default capacity of the lists that are used to store the chaining and non-chaining inhibition definitions.
 
static const std::string DEF_LAYER_NAME = "BehaviourLayer"
 Default behaviour layer name used to generate a unique one, in the case that no name is provided by a derived behaviour layer class.
 

Protected Member Functions

void addInhibition (Behaviour *BBaseA, Behaviour *BBaseB)
 Adds a non-chaining inhibition from behaviour BBaseA (inhibitor) to behaviour BBaseB (inhibitee). More...
 
void addChainInhibition (Behaviour *BBaseA, Behaviour *BBaseB)
 Adds a chaining inhibition from behaviour BBaseA (inhibitor) to behaviour BBaseB (inhibitee). More...
 
virtual ret_t init ()
 Initialisation callback for the behaviour layer. This function is called from initAll(), and is intended to be overridden for the purpose of initialising the derived behaviour layer object.
 
virtual void update ()
 Update callback for the behaviour layer object. This function is called from updateAll(), which is used in step().
 
virtual void postExecuteCallback ()
 Callback that is invoked at the end of the executeAll() function so that the user can inject code.
 

Friends

class BehaviourManager
 
class SensorManager
 
class ActuatorManager
 
class Behaviour
 

Detailed Description

Implements a single behaviour layer.

This class is the base class of all behavioural layers that are used in an architecture.

Constructor & Destructor Documentation

BehaviourLayer::BehaviourLayer ( BehaviourManager MBase,
const std::string &  name = nullString,
bool  isInterface = false 
)
explicit

Default constructor.

Note that although the default value for the name parameter is nullString, this will not actually become the behaviour layer's name if the parameter is omitted. This is just used to signal to the class's internals that it should generate a default name using the getUniqueName() function. MBase must never be null or a segmentation fault will result!

Parameters
MBaseA pointer to the behaviour manager that the behaviour layer belongs to.
nameThe human-friendly name to give the behaviour layer (null means auto-generate).
isInterfaceA boolean flag specifying whether the layer is an interface layer. This changes what you are allowed to do with the class in some situations, and ensures that the execution order is right for an external interface.

Member Function Documentation

void BehaviourLayer::addChainInhibition ( Behaviour BBaseA,
Behaviour BBaseB 
)
protected

Adds a chaining inhibition from behaviour BBaseA (inhibitor) to behaviour BBaseB (inhibitee).

Add a chaining (transitive) inhibition from behaviour A to behaviour B. Neither behaviour pointer should be null, the behaviours pointers can't be equal, and both behaviours should belong to the behaviour layer for which this function is called. This function can only be used in the constructor of the derived layer class.

Parameters
BBaseAA non-null pointer to the behaviour that is inhibiting.
BBaseBA non-null pointer to the behaviour that is being inhibited.
void BehaviourLayer::addInhibition ( Behaviour BBaseA,
Behaviour BBaseB 
)
protected

Adds a non-chaining inhibition from behaviour BBaseA (inhibitor) to behaviour BBaseB (inhibitee).

Add a non-chaining (non-transitive) inhibition from behaviour A to behaviour B. Neither behaviour pointer should be null, the behaviours pointers can't be equal, and both behaviours should belong to the behaviour layer for which this function is called. This function can only be used in the constructor of the derived layer class.

Parameters
BBaseAA non-null pointer to the behaviour that is inhibiting.
BBaseBA non-null pointer to the behaviour that is being inhibited.
std::string BehaviourLayer::getUniqueName ( const BehaviourManager MBase) const

Returns a unique behaviour layer name.

Automatically construct a unique name for the behaviour layer, for situations where none is provided by the derived class. The name that results of this function will be unique as long as the user does not explicitly use the same name somewhere else, either before or after the construction of this layer. If there are currently two layers in the MBase manager, the generated name will be the concatenation of DEF_LAYER_NAME and "2".

Parameters
MBaseA non-null pointer to the parent behaviour manager.
Returns
The required layer name.

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