RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
StateStructure Class Reference

the StateStructure is responsible for handling a structure of StateData and Frames More...

#include <StateStructure.hpp>

Public Types

typedef rw::core::Ptr< StateStructurePtr
 smart pointer type of this class
 
typedef boost::function< void(const kinematics::StateData *)> StateDataAddedListener
 Defines a listener for StateData added events. More...
 
typedef boost::function< void(const kinematics::StateData *)> StateDataRemovedListener
 Defines a listener for StateData removed events. More...
 
typedef rw::core::Event< StateDataAddedListener, const kinematics::StateData * > StateDataAddedEvent
 Defines event for StateData added.
 
typedef rw::core::Event< StateDataRemovedListener, const kinematics::StateData * > StateDataRemovedEvent
 Defines event for StateData removed.
 

Public Member Functions

 StateStructure ()
 constructs a frame tree with a default root frame with the name "WORLD".
 
virtual ~StateStructure ()
 destructor
 
bool has (rw::core::Ptr< const StateData > data)
 tests if StateData data exist in this StateStructure More...
 
int getMaxID () const
 gets the max ID of any StateData/Frame currently in the tree. More...
 
void addData (StateData *data)
 adds a statedata to the frame tree and allocates memory for its states. This method updates the default state. More...
 
void addData (rw::core::Ptr< StateData > data)
 adds a statedata to the frame tree and allocates memory for its states. This method updates the default state. More...
 
void addFrame (rw::core::Ptr< Frame > frame, rw::core::Ptr< Frame > parent=NULL)
 adds a frame to the frame tree and statically associates the frame with the parent frame. This method updates the default state. More...
 
void addDAF (rw::core::Ptr< Frame > frame, rw::core::Ptr< Frame > parent)
 adds a DAF to the frame tree and dynamicly associates the frame with a parent frame. More...
 
void remove (rw::core::Ptr< StateData > data)
 removes a StateData object from the tree. The actual deletion of the object will happen when no States depend on the StateData anymore. More...
 
State upgradeState (const State &oldState)
 upgrades the state to the default state, but without clearing the values of the state. More...
 
const StategetDefaultState () const
 get the default state of the frame tree More...
 
void setDefaultState (const State &state)
 set the default state of the dynamic frame tree if the given state is an older state then states valid in both new and old version will be copied to the default state.
 
const std::vector< rw::core::Ptr< StateData > > & getStateData () const
 All state data in the tree. More...
 
const std::vector< Frame * > & getFrames () const
 All frames of the tree. Notice that elements in this vector can be NULL. More...
 
const std::vector< Frame * > & getDAFs () const
 All DAFs of the tree. More...
 
const FramegetRoot () const
 get root of state structure More...
 
rw::kinematics::FramegetRoot ()
 get root of state structure More...
 
void cleanup (int ID=-1)
 destructs all frames and statedata that is not used any more. More...
 
kinematics::FramefindFrame (const std::string &name) const
 Returns frame with the specified name. More...
 
rw::core::Ptr< kinematics::StateDatafindData (const std::string &name) const
 Find data from name. More...
 
StateDataAddedEventstateDataAddedEvent ()
 Returns StateDataAddedEvent object needed for subscription to and firing of event. More...
 
StateDataRemovedEventstateDataRemovedEvent ()
 Returns StateDataRemovedEvent object needed for subscription to and firing of event. More...
 

Detailed Description

the StateStructure is responsible for handling a structure of StateData and Frames

Member Typedef Documentation

◆ StateDataAddedListener

typedef boost::function<void(const kinematics::StateData*)> StateDataAddedListener

Defines a listener for StateData added events.

Parameters
StateData[in] the statedata that has been added

◆ StateDataRemovedListener

typedef boost::function<void(const kinematics::StateData*)> StateDataRemovedListener

Defines a listener for StateData removed events.

Parameters
StateData[in] the statedata that has been removed.

Member Function Documentation

◆ addDAF()

void addDAF ( rw::core::Ptr< Frame frame,
rw::core::Ptr< Frame parent 
)

adds a DAF to the frame tree and dynamicly associates the frame with a parent frame.

Note
the parent frame must exist in the frame tree and cannot be NULL.

◆ addData() [1/2]

void addData ( rw::core::Ptr< StateData data)

adds a statedata to the frame tree and allocates memory for its states. This method updates the default state.

Note
Ownership is not taken, the data object may not have been added to any StateStructure before.

◆ addData() [2/2]

void addData ( StateData data)

adds a statedata to the frame tree and allocates memory for its states. This method updates the default state.

Note
Ownership is taken, the data object may not have been added to any StateStructure before.

◆ addFrame()

void addFrame ( rw::core::Ptr< Frame frame,
rw::core::Ptr< Frame parent = NULL 
)

adds a frame to the frame tree and statically associates the frame with the parent frame. This method updates the default state.

If parent frame is null then the frame will be attached to the world frame.

◆ cleanup()

void cleanup ( int  ID = -1)

destructs all frames and statedata that is not used any more.

Parameters
ID[in] used to include a specific StateData ID for destruction, defualt -1 to ignore this option.

◆ findData()

rw::core::Ptr<kinematics::StateData> findData ( const std::string &  name) const

Find data from name.

Parameters
name[in] the name.
Returns
the data if found.

◆ findFrame()

kinematics::Frame* findFrame ( const std::string &  name) const

Returns frame with the specified name.

If multiple frames has the same name, the first frame encountered will be returned. If no frame is found, the method returns NULL.

Parameters
name[in] name of Frame.
Returns
The frame with name name or NULL if no such frame.

◆ getDAFs()

const std::vector<Frame*>& getDAFs ( ) const
inline

All DAFs of the tree.

Returns
All DAFs of the tree.

◆ getDefaultState()

const State& getDefaultState ( ) const

get the default state of the frame tree

Returns
the default tree state

◆ getFrames()

const std::vector<Frame*>& getFrames ( ) const
inline

All frames of the tree. Notice that elements in this vector can be NULL.

Returns
All frames of the tree.

◆ getMaxID()

int getMaxID ( ) const
inline

gets the max ID of any StateData/Frame currently in the tree.

All frame/data IDs (see StateData::getID()) for the data of the tree are lower than this number (and greater than or equal to zero).

◆ getRoot() [1/2]

rw::kinematics::Frame* getRoot ( )
inline

get root of state structure

Returns
the root frame of the StateStructure

◆ getRoot() [2/2]

const Frame* getRoot ( ) const
inline

get root of state structure

Returns
the root frame of the StateStructure

◆ getStateData()

const std::vector<rw::core::Ptr<StateData> >& getStateData ( ) const
inline

All state data in the tree.

Returns
All state data in the tree

◆ has()

bool has ( rw::core::Ptr< const StateData data)

tests if StateData data exist in this StateStructure

Returns
true if the data was found, false otherwise
Note
the search includes the union of StateData in all StateSetup's that belong to the StateStructure

◆ remove()

void remove ( rw::core::Ptr< StateData data)

removes a StateData object from the tree. The actual deletion of the object will happen when no States depend on the StateData anymore.

Parameters
data[in] pointer to object that is to be removed
Note
if the data object is a frame and it has staticly connected children then the remove operation is illigal.
if the data object is a frame and it has dynamicly attached children then all of these will change parent relation ship such that world will become their parent.

◆ stateDataAddedEvent()

StateDataAddedEvent& stateDataAddedEvent ( )
inline

Returns StateDataAddedEvent object needed for subscription to and firing of event.

Returns
Reference to the StateDataAddedEvent

◆ stateDataRemovedEvent()

StateDataRemovedEvent& stateDataRemovedEvent ( )
inline

Returns StateDataRemovedEvent object needed for subscription to and firing of event.

Returns
Reference to the StateDataRemovedEvent

◆ upgradeState()

State upgradeState ( const State oldState)

upgrades the state to the default state, but without clearing the values of the state.

Parameters
oldState[in] the state that should be upgraded
Returns
the upgraded state

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