LibCT 2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes

LibCT::Node Class Reference

A Node is a class used as the base for all conversation tree items. More...

#include <Node.h>

Inheritance diagram for LibCT::Node:
LibCT::ConversationNode LibCT::DecisionNode LibCT::PhaseNode

List of all members.

Public Member Functions

 Node (Node *pParent, NodeType type, const std::string text)
 Constructor.
virtual ~Node ()
 Destructor.
bool Serialise (InputStream *pInput)
bool Serialise (OutputStream *pOutput)
virtual bool SerialiseImpl (InputStream *pInput)
virtual bool SerialiseImpl (OutputStream *pOutput)
NodeGetParent () const
NodeType GetType () const
std::string GetText () const
void SetText (const std::string &text)
 Set the text of this node.
const std::string & GetParsedText ()
 Get the text, but after it has been parsed for variables.
void AddChild (Node *pNode, int index=-1)
 Add a child to this node, will remove from old parent if needed.
void RemoveChild (Node *pNode)
 Remove a child from this node.
NodeGetChildByIndex (unsigned int index) const
NodeGetChildById (NodeId) const
unsigned int GetNumChildren () const
bool IsChildNode (Node *pNode) const
int GetChildIndex (Node *) const
NodeId GetId () const
ConversationNodeGetRoot () const
virtual NodeGetNext ()
void ConnectTo (Node *pNode, unsigned int index)
 Set a connection.
NodeGetConnection (unsigned int index) const
EventTypeGetEvent (unsigned int index) const
void SetEvent (unsigned int index, const std::string &eventName)
 Set the event at index.

Static Public Member Functions

static NodeCreate (InputStream *pInput, Node *pParent)

Static Public Attributes

static const unsigned int MAX_CONNECTIONS = 2
 The maximum number of nodes a node can connect to.
static const unsigned int MAX_EVENTS = 4
 The maximum number of events a node can fire.

Protected Member Functions

void SetParent (Node *pNode)
 Set the parent of this node, will remove from old parent if needed.
void SetId (NodeId id)
bool SerialiseConnections (InputStream *pInput)
bool SerialiseConnections (OutputStream *pOutput)
void FireEvent (unsigned int index) const
 Fire an event, if it exists.

Protected Attributes

NodeId m_Id
 Unique id for this node.
Nodem_pParent
 Parent node (may be null)
ConversationNodem_pRoot
 Root ConversationNode for the tree this node belongs to.
Nodem_pConnected [MAX_CONNECTIONS]
 The nodes this oen is connected to.
EventTypem_pEvents [MAX_EVENTS]
 List of events.
NodeType m_Type
 Type of this node.
std::string m_Text
 Text for this node.
std::string m_ParsedText
 Parsed text of the node.
NodeList m_Children
 List of nodes that are children of this node.

Detailed Description

A Node is a class used as the base for all conversation tree items.


Constructor & Destructor Documentation

LibCT::Node::Node ( Node pParent,
NodeType  type,
const std::string  text 
)

Constructor.

Parameters:
pParentNodes parent
typeType of this node
textText for this node
virtual LibCT::Node::~Node ( ) [virtual]

Destructor.


Member Function Documentation

void LibCT::Node::AddChild ( Node pNode,
int  index = -1 
)

Add a child to this node, will remove from old parent if needed.

Parameters:
pNodeNode to add
indexIndex to add node, (-1 adds to back)
void LibCT::Node::ConnectTo ( Node pNode,
unsigned int  index 
)

Set a connection.

Parameters:
pNodeNode to connect to
indexConnection index
static Node* LibCT::Node::Create ( InputStream pInput,
Node pParent 
) [static]

Serialise a node fromt the stream

Returns:
A new node serialised from the stream, or 0 on failure
void LibCT::Node::FireEvent ( unsigned int  index) const [protected]

Fire an event, if it exists.

Parameters:
indexIndex of m_pEvents array to fire
Node* LibCT::Node::GetChildById ( NodeId  ) const

Get a child node by NodeId

Returns:
The child node with the specified NodeId, or null if no child nodes have that id
Node* LibCT::Node::GetChildByIndex ( unsigned int  index) const

Get a child node by index

Returns:
The child at index, or null if index is out of bounds
Parameters:
indexIndex of child to return
int LibCT::Node::GetChildIndex ( Node ) const

Get the index of a child node

Returns:
The index of the child node, or -1 if childNode is not found
Node* LibCT::Node::GetConnection ( unsigned int  index) const

Get the connected node at a specified index

Returns:
The connected Node* at index (may be null)
Parameters:
indexConnection index
EventType* LibCT::Node::GetEvent ( unsigned int  index) const

Get the event at index

Returns:
The EventType at index (may be null)
Parameters:
indexIndex to return
NodeId LibCT::Node::GetId ( ) const [inline]

Get the NodeId for this node

Returns:
The NodeId for this node
virtual Node* LibCT::Node::GetNext ( ) [virtual]

Get active connection

Returns:
The node this one is actively connected to

Reimplemented in LibCT::ConversationNode, and LibCT::DecisionNode.

unsigned int LibCT::Node::GetNumChildren ( ) const [inline]

Get the number of children this node has

Returns:
The number of children this node has
Node* LibCT::Node::GetParent ( ) const [inline]

Get the parent node

Returns:
This nodes parent node
const std::string& LibCT::Node::GetParsedText ( )

Get the text, but after it has been parsed for variables.

ConversationNode* LibCT::Node::GetRoot ( ) const [inline]

Get the root node

Returns:
The root ConversationNode of this tree
std::string LibCT::Node::GetText ( ) const [inline]

Get the text of this node

Returns:
The text of this node
NodeType LibCT::Node::GetType ( ) const [inline]

Get the type of this node

Returns:
The type of this node
bool LibCT::Node::IsChildNode ( Node pNode) const

Test if a node is a child-node of this node

Returns:
True if pNode is a child node of this node
Parameters:
pNodeNode to test
void LibCT::Node::RemoveChild ( Node pNode)

Remove a child from this node.

Parameters:
pNodeNode to remove
bool LibCT::Node::Serialise ( InputStream pInput)

Serialise this node (and it's children) from a stream

Returns:
True if successful
bool LibCT::Node::Serialise ( OutputStream pOutput)

Serialise this node (and it's children) to a stream

Returns:
True if successful
bool LibCT::Node::SerialiseConnections ( OutputStream pOutput) [protected]

Serialise this nodes connections (and that of it's children) to a stream

Returns:
True if successful
bool LibCT::Node::SerialiseConnections ( InputStream pInput) [protected]

Serialise this nodes connections (and that of it's children) from a stream

Returns:
True if successful
virtual bool LibCT::Node::SerialiseImpl ( OutputStream pOutput) [virtual]

Implementation of serialisation

Returns:
True if successful

Reimplemented in LibCT::ConversationNode, and LibCT::DecisionNode.

virtual bool LibCT::Node::SerialiseImpl ( InputStream pInput) [virtual]

Implementation of serialisation

Returns:
True if successful

Reimplemented in LibCT::ConversationNode, and LibCT::DecisionNode.

void LibCT::Node::SetEvent ( unsigned int  index,
const std::string &  eventName 
)

Set the event at index.

Parameters:
indexIndex to set
eventNameName of the event to set
void LibCT::Node::SetId ( NodeId  id) [inline, protected]

Set the NodeId for this node Setting this to a node ID already in use would be bad

void LibCT::Node::SetParent ( Node pNode) [protected]

Set the parent of this node, will remove from old parent if needed.

Parameters:
pNodeNew parent node
void LibCT::Node::SetText ( const std::string &  text) [inline]

Set the text of this node.


Member Data Documentation

List of nodes that are children of this node.

Unique id for this node.

std::string LibCT::Node::m_ParsedText [protected]

Parsed text of the node.

The nodes this oen is connected to.

List of events.

Parent node (may be null)

Root ConversationNode for the tree this node belongs to.

std::string LibCT::Node::m_Text [protected]

Text for this node.

Type of this node.

const unsigned int LibCT::Node::MAX_CONNECTIONS = 2 [static]

The maximum number of nodes a node can connect to.

const unsigned int LibCT::Node::MAX_EVENTS = 4 [static]

The maximum number of events a node can fire.


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