Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

zeitgeist::Leaf Class Reference

Leaf defines the beginning of the hierarchy. More...

#include <leaf.h>

Inheritance diagram for zeitgeist::Leaf:

Inheritance graph
[legend]
Collaboration diagram for zeitgeist::Leaf:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::list< boost::shared_ptr<
Leaf > > 
TLeafList

Public Member Functions

 Leaf (const std::string &name="<unnamed>")
 constructs a leaf with the given name
virtual ~Leaf ()
std::string & GetName ()
 returns a reference to the name of the leaf
const std::string & GetName () const
 returns a constant reference to the name of the leaf
boost::weak_ptr< Node > & GetParent ()
 returns a pointer to the parent of the leaf
const boost::weak_ptr< Node > & GetParent () const
 returns a constant pointer to the parent of the leaf
virtual boost::shared_ptr<
Leaf
GetChild (const std::string &name, bool recursive=false)
 defines an interface to get a pointer to a child (i.e.
virtual boost::shared_ptr<
Leaf
GetChildOfClass (const std::string &name, bool recursive=false)
 defines an interface to get a pointer to child of the given class type, which can be searched recursively.
virtual boost::shared_ptr<
Leaf
GetChildSupportingClass (const std::string &name, bool recursive=false)
 defines an interface to get the fist child supporting the class 'name' (i.e.
template<class CLASS>
boost::shared_ptr< CLASS > FindChildSupportingClass (bool recursive=false)
 defines an interface to get the fist child supporting the class 'name' (i.e.
virtual void GetChildren (const std::string &name, TLeafList &baseList, bool recursive=false)
 defines an interface to get a list of children.
virtual void GetChildrenOfClass (const std::string &name, TLeafList &baseList, bool recursive=false)
 defines an interface to get a list to all children of type 'name'.
virtual void GetChildrenSupportingClass (const std::string &name, TLeafList &baseList, bool recursive=false)
 defines an interface to get a list to all children supporting a class 'name' i.e.
template<class CLASS>
void ListChildrenSupportingClass (TLeafList &list, bool recursive=false)
 constructs a list of all children supporting a class 'name' i.e.
virtual boost::weak_ptr< NodeGetParentSupportingClass (const std::string &name) const
 defines an interface to get the first parent node on the way up the hierarchy that supports a class 'name', i.e.
template<class CLASS>
boost::weak_ptr< CLASS > FindParentSupportingClass () const
 defines an interface to get the first parent node on the way up the hierarchy that supports a class 'name', i.e.
virtual bool IsLeaf () const
 defines an interface to test if this node is a leaf.
virtual void RemoveChildReference (const boost::shared_ptr< Leaf > &base)
 removes base from the set of children.
virtual bool AddChildReference (const boost::shared_ptr< Leaf > &base)
 adds base to the set of children and sets the parent of base to be this node
void Unlink ()
 detaches this node and its hierarchy from its parent.
virtual void UnlinkChildren ()
 unlinks all child nodes
virtual void Dump () const
 writes debug data to stdout
virtual void UpdateCached ()
 update variables from a script
const std::string & GetFullPath () const
 constructs the full path of this node by walking up the tree.
void ClearCachedData () const
 clears any cached data (e.g.
void SetName (const std::string &name)
 sets the name of this node
virtual TLeafList::iterator begin ()
virtual TLeafList::const_iterator begin () const
virtual TLeafList::iterator end ()
virtual TLeafList::const_iterator end () const

Protected Member Functions

virtual void UpdateCachedInternal ()
 called from within UpdatCached; override to perform node specific updates
void SetParent (const boost::shared_ptr< Node > &parent)
 Sets the parent of this node.
virtual void OnLink ()
 This method is called, when the hierarchy object has been linked to a parent.
virtual void OnUnlink ()
 This rountine is called, before the hierarchy object is removed from the parent.

Protected Attributes

boost::weak_ptr< NodemParent
 This pointer holds a link to the parent of this node.

Private Member Functions

 Leaf (const Leaf &obj)
Leafoperator= (const Leaf &obj)

Private Attributes

std::string mName
 the name of the node
std::string * mCachedFullPath
 temporary cached full path of this node in the hierarchy

Friends

class Node

Detailed Description

Leaf defines the beginning of the hierarchy.

A Leaf object can reside within the hierarchy, but cannot have children!

Definition at line 50 of file leaf.h.


Member Typedef Documentation

typedef std::list< boost::shared_ptr<Leaf> > zeitgeist::Leaf::TLeafList
 

Definition at line 57 of file leaf.h.


Constructor & Destructor Documentation

Leaf::Leaf const std::string &  name = "<unnamed>"  ) 
 

constructs a leaf with the given name

Definition at line 30 of file leaf.cpp.

Leaf::~Leaf  )  [virtual]
 

Definition at line 34 of file leaf.cpp.

zeitgeist::Leaf::Leaf const Leaf obj  )  [private]
 


Member Function Documentation

bool Leaf::AddChildReference const boost::shared_ptr< Leaf > &  base  )  [virtual]
 

adds base to the set of children and sets the parent of base to be this node

Reimplemented in zeitgeist::Node.

Definition at line 123 of file leaf.cpp.

Leaf::TLeafList::const_iterator Leaf::begin  )  const [virtual]
 

Reimplemented in zeitgeist::Node.

Definition at line 183 of file leaf.cpp.

References gFakeChildren.

Leaf::TLeafList::iterator Leaf::begin  )  [virtual]
 

Reimplemented in zeitgeist::Node.

Definition at line 178 of file leaf.cpp.

References gFakeChildren.

Referenced by FindChildSupportingClass(), and ListChildrenSupportingClass().

void Leaf::ClearCachedData  )  const
 

clears any cached data (e.g.

the cached full path and forces the node to recalculate all values

Definition at line 170 of file leaf.cpp.

References mCachedFullPath.

Referenced by SetName(), and SetParent().

void Leaf::Dump  )  const [virtual]
 

writes debug data to stdout

Reimplemented from zeitgeist::Object.

Reimplemented in zeitgeist::Node.

Definition at line 138 of file leaf.cpp.

References zeitgeist::Object::Dump(), and GetName().

Referenced by zeitgeist::Node::Dump().

Here is the call graph for this function:

Leaf::TLeafList::const_iterator Leaf::end  )  const [virtual]
 

Reimplemented in zeitgeist::Node.

Definition at line 193 of file leaf.cpp.

References gFakeChildren.

Leaf::TLeafList::iterator Leaf::end  )  [virtual]
 

Reimplemented in zeitgeist::Node.

Definition at line 188 of file leaf.cpp.

References gFakeChildren.

Referenced by FindChildSupportingClass(), and ListChildrenSupportingClass().

template<class CLASS>
boost::shared_ptr<CLASS> zeitgeist::Leaf::FindChildSupportingClass bool  recursive = false  )  [inline]
 

defines an interface to get the fist child supporting the class 'name' (i.e.

nodes of a type equal to or derived from the class 'name'), which can be searched recursively. The class Leaf will always return an empty reference. This implementation of FindChildSupportingClass does not rely on the associated zeitgeist class name but uses the c++ typeid system.

Definition at line 112 of file leaf.h.

References begin(), CLASS, and end().

Here is the call graph for this function:

template<class CLASS>
boost::weak_ptr< CLASS > zeitgeist::Leaf::FindParentSupportingClass  )  const
 

defines an interface to get the first parent node on the way up the hierarchy that supports a class 'name', i.e.

is an instance of that class or is derived from it. This implementation of GetParentSupportingClass does not rely on the associated zeitgeist class name but uses the c++ typeid system.

Definition at line 129 of file node.h.

References GetParent().

Here is the call graph for this function:

boost::shared_ptr< Leaf > Leaf::GetChild const std::string &  name,
bool  recursive = false
[virtual]
 

defines an interface to get a pointer to a child (i.e.

node or leaf) with the given name, which can be searched recursively. The class Leaf will always return an empty reference

Reimplemented in zeitgeist::Node.

Definition at line 48 of file leaf.cpp.

References GetParent(), and zeitgeist::Object::GetSelf().

Referenced by zeitgeist::Node::GetChild().

Here is the call graph for this function:

boost::shared_ptr< Leaf > Leaf::GetChildOfClass const std::string &  name,
bool  recursive = false
[virtual]
 

defines an interface to get a pointer to child of the given class type, which can be searched recursively.

The class Leaf will always return an empty reference

Reimplemented in zeitgeist::Node.

Definition at line 64 of file leaf.cpp.

void Leaf::GetChildren const std::string &  name,
TLeafList baseList,
bool  recursive = false
[virtual]
 

defines an interface to get a list of children.

The Leaf class will always return an empty list

Definition at line 74 of file leaf.cpp.

References GetParent(), and zeitgeist::Object::GetSelf().

Referenced by zeitgeist::Node::GetChildren().

Here is the call graph for this function:

void Leaf::GetChildrenOfClass const std::string &  name,
TLeafList baseList,
bool  recursive = false
[virtual]
 

defines an interface to get a list to all children of type 'name'.

The Leaf class will always return an empty list

Definition at line 87 of file leaf.cpp.

Referenced by zeitgeist::Node::GetChildrenOfClass().

void Leaf::GetChildrenSupportingClass const std::string &  name,
TLeafList baseList,
bool  recursive = false
[virtual]
 

defines an interface to get a list to all children supporting a class 'name' i.e.

they are an instance of that class or are derived from it. The Leaf class will always return an empty list

Definition at line 91 of file leaf.cpp.

Referenced by zeitgeist::Node::GetChildrenSupportingClass().

boost::shared_ptr< Leaf > Leaf::GetChildSupportingClass const std::string &  name,
bool  recursive = false
[virtual]
 

defines an interface to get the fist child supporting the class 'name' (i.e.

nodes of a type equal to or derived from the class 'name'), which can be searched recursively. The class Leaf will always return an empty reference

Reimplemented in zeitgeist::Node.

Definition at line 69 of file leaf.cpp.

const std::string & Leaf::GetFullPath  )  const
 

constructs the full path of this node by walking up the tree.

Cosecutive calls return a cached copy of the full path to avoid the expensive tree walk.

Definition at line 144 of file leaf.cpp.

References GetParent(), IsLeaf(), mCachedFullPath, and mName.

Referenced by zeitgeist::Object::GetClass(), and zeitgeist::Object::GetCore().

Here is the call graph for this function:

const std::string& zeitgeist::Leaf::GetName  )  const [inline]
 

returns a constant reference to the name of the leaf

Definition at line 72 of file leaf.h.

References mName.

std::string& zeitgeist::Leaf::GetName  )  [inline]
 

returns a reference to the name of the leaf

Definition at line 68 of file leaf.h.

References mName.

Referenced by oxygen::NetControl::AcceptTCPConnections(), oxygen::NetClient::CloseConnection(), oxygen::NetClient::Connect(), oxygen::NetControl::DoneSimulation(), Dump(), zeitgeist::Object::GetClass(), zeitgeist::Object::GetCore(), zeitgeist::Class::GetCore(), UniversalJointEffector::GetPredicate(), HingeEffector::GetPredicate(), Hinge2Effector::GetPredicate(), SoccerBase::GetSoccerVar(), oxygen::NetControl::InitSimulation(), oxygen::NetClient::ReadFragments(), oxygen::NetControl::ReadTCPMessages(), oxygen::NetControl::ReadUDPMessages(), and zeitgeist::Class::SupportsClass().

const boost::weak_ptr< Node > & Leaf::GetParent  )  const
 

returns a constant pointer to the parent of the leaf

Definition at line 43 of file leaf.cpp.

References mParent.

boost::weak_ptr< Node > & Leaf::GetParent  ) 
 

returns a pointer to the parent of the leaf

Definition at line 38 of file leaf.cpp.

References mParent.

Referenced by FindParentSupportingClass(), GetChild(), GetChildren(), GetFullPath(), GetParentSupportingClass(), oxygen::SimControlNode::GetSimulationServer(), SayEffector::OnLink(), KickEffector::OnLink(), ForceEffector::OnLink(), oxygen::CollisionHandler::OnLink(), oxygen::Collider::OnLink(), CatchEffector::OnLink(), oxygen::Body::OnLink(), AgentStatePerceptor::Percept(), oxygen::Body::PostPhysicsUpdateInternal(), PanTiltEffector::Realize(), DriveEffector::Realize(), and SetParent().

boost::weak_ptr< Node > Leaf::GetParentSupportingClass const std::string &  name  )  const [virtual]
 

defines an interface to get the first parent node on the way up the hierarchy that supports a class 'name', i.e.

is an instance of that class or is derived from it.

Definition at line 96 of file leaf.cpp.

References GetParent().

Referenced by oxygen::Effector::GetAgentAspect(), and oxygen::BodyController::OnLink().

Here is the call graph for this function:

bool Leaf::IsLeaf  )  const [virtual]
 

defines an interface to test if this node is a leaf.

Only the TLeaf class will return true

Reimplemented in zeitgeist::Node.

Definition at line 114 of file leaf.cpp.

Referenced by GetFullPath().

template<class CLASS>
void zeitgeist::Leaf::ListChildrenSupportingClass TLeafList list,
bool  recursive = false
[inline]
 

constructs a list of all children supporting a class 'name' i.e.

they are an instance of that class or are derived from it. This implementation of GetChildrenSupportingClass does not rely on the associated zeitgeist class name but uses the c++ typeid system.

Definition at line 155 of file leaf.h.

References begin(), CLASS, and end().

Here is the call graph for this function:

void Leaf::OnLink  )  [protected, virtual]
 

This method is called, when the hierarchy object has been linked to a parent.

At that point, traversal can commence. It can be overridden to support custom 'link' behavior.

Reimplemented in kerosin::InputControl, kerosin::MaterialServer, kerosin::RenderControl, kerosin::RenderServer, kerosin::Box, kerosin::Light, kerosin::Sphere, kerosin::TextureServer, oxygen::GeometryServer, oxygen::AngularMotor, oxygen::BallJoint, oxygen::Body, oxygen::BodyController, oxygen::Collider, oxygen::CollisionHandler, oxygen::FixedJoint, oxygen::Hinge2Joint, oxygen::HingeJoint, oxygen::Joint, oxygen::SliderJoint, oxygen::UniversalJoint, oxygen::Camera, oxygen::Transform, oxygen::AgentControl, oxygen::MonitorControl, oxygen::SimulationServer, oxygen::SpadesServer, ForceEffector, AgentStatePerceptor, BallStateAspect, BeamEffector, CatchEffector, DriveEffector, GameStateAspect, GameStateItem, GameStatePerceptor, HearPerceptor, InitEffector, KickEffector, ObjectState, PanTiltEffector, RestrictedVisionPerceptor, SayEffector, SexpMonitor, SoccerControlAspect, SoccerRuleAspect, TrainerCommandParser, VisionPerceptor, SoccerInput, SoccerRender, Hinge2Effector, Hinge2Perceptor, HingeEffector, HingePerceptor, TimePerceptor, UniversalJointEffector, UniversalJointPerceptor, SparkMonitor, and SparkMonitorClient.

Definition at line 237 of file leaf.cpp.

Referenced by ObjectState::OnLink(), oxygen::MonitorControl::OnLink(), oxygen::Collider::OnLink(), oxygen::Body::OnLink(), oxygen::AgentControl::OnLink(), and SetParent().

void Leaf::OnUnlink  )  [protected, virtual]
 

This rountine is called, before the hierarchy object is removed from the parent.

It can be overridden to support custom 'unlink' behavior.

Reimplemented in kerosin::InputControl, kerosin::RenderControl, kerosin::RenderServer, kerosin::Light, kerosin::TextureServer, oxygen::BodyController, oxygen::Collider, oxygen::CollisionHandler, oxygen::SceneServer, oxygen::AgentControl, oxygen::MonitorControl, oxygen::SimulationServer, oxygen::SpadesServer, zeitgeist::FileServer, ForceEffector, AgentStatePerceptor, BallStateAspect, BeamEffector, CatchEffector, DriveEffector, GameStateItem, GameStatePerceptor, HearPerceptor, InitEffector, KickEffector, ObjectState, PanTiltEffector, RestrictedVisionPerceptor, SayEffector, SexpMonitor, SoccerRuleAspect, TrainerCommandParser, VisionPerceptor, SoccerInput, SoccerRender, Hinge2Effector, Hinge2Perceptor, HingeEffector, HingePerceptor, TimePerceptor, UniversalJointEffector, UniversalJointPerceptor, SparkMonitor, and SparkMonitorClient.

Definition at line 241 of file leaf.cpp.

Referenced by SoccerRuleAspect::OnUnlink(), ObjectState::OnUnlink(), oxygen::MonitorControl::OnUnlink(), oxygen::Collider::OnUnlink(), BallStateAspect::OnUnlink(), oxygen::AgentControl::OnUnlink(), and SetParent().

Leaf& zeitgeist::Leaf::operator= const Leaf obj  )  [private]
 

void Leaf::RemoveChildReference const boost::shared_ptr< Leaf > &  base  )  [virtual]
 

removes base from the set of children.

Reimplemented in zeitgeist::Node.

Definition at line 119 of file leaf.cpp.

void zeitgeist::Leaf::SetName const std::string &  name  )  [inline]
 

sets the name of this node

Definition at line 244 of file leaf.h.

References ClearCachedData(), and mName.

Referenced by oxygen::AgentAspect::AgentAspect(), oxygen::Camera::Camera(), Hinge2Effector::Hinge2Effector(), HingeEffector::HingeEffector(), oxygen::Transform::Transform(), and UniversalJointEffector::UniversalJointEffector().

Here is the call graph for this function:

void Leaf::SetParent const boost::shared_ptr< Node > &  parent  )  [protected]
 

Sets the parent of this node.

It has to be implemented 'very carefully'. The parent object always holds a shared pointer reference to mSelf. What we have to do is 'get' the shared reference, remove it from the old parent. Insert it into the new parent and change the parent pointer.

Definition at line 198 of file leaf.cpp.

References ClearCachedData(), GetParent(), zeitgeist::Object::GetSelf(), mParent, OnLink(), and OnUnlink().

Referenced by Unlink().

Here is the call graph for this function:

void Leaf::Unlink  ) 
 

detaches this node and its hierarchy from its parent.

Definition at line 128 of file leaf.cpp.

References SetParent().

Here is the call graph for this function:

void Leaf::UnlinkChildren  )  [virtual]
 

unlinks all child nodes

Reimplemented in zeitgeist::Node.

Definition at line 134 of file leaf.cpp.

virtual void zeitgeist::Leaf::UpdateCached  )  [inline, virtual]
 

update variables from a script

Reimplemented in oxygen::SpadesServer, zeitgeist::Node, and SexpMonitor.

Definition at line 232 of file leaf.h.

virtual void zeitgeist::Leaf::UpdateCachedInternal  )  [inline, protected, virtual]
 

called from within UpdatCached; override to perform node specific updates

Reimplemented in SoccerRuleAspect.

Definition at line 256 of file leaf.h.


Friends And Related Function Documentation

friend class Node [friend]
 

Definition at line 52 of file leaf.h.


Member Data Documentation

std::string* zeitgeist::Leaf::mCachedFullPath [mutable, private]
 

temporary cached full path of this node in the hierarchy

Definition at line 299 of file leaf.h.

Referenced by ClearCachedData(), and GetFullPath().

std::string zeitgeist::Leaf::mName [private]
 

the name of the node

Definition at line 296 of file leaf.h.

Referenced by GetFullPath(), GetName(), and SetName().

boost::weak_ptr<Node> zeitgeist::Leaf::mParent [protected]
 

This pointer holds a link to the parent of this node.

It has to be at least a Node, as that is the first class, which can hold children. We use a weak pointer to break the cyclic dependency.

Definition at line 292 of file leaf.h.

Referenced by GetParent(), oxygen::BaseNode::GetWorldTransform(), SetParent(), oxygen::Transform::SetWorldTransform(), oxygen::BaseNode::SetWorldTransform(), and oxygen::Transform::UpdateHierarchyInternal().


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:50:19 2006 for rcssserver3d by  doxygen 1.4.4