LibCT 2.0
|
A Node is a class used as the base for all conversation tree items. More...
#include <Node.h>
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) |
Node * | GetParent () 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. | |
Node * | GetChildByIndex (unsigned int index) const |
Node * | GetChildById (NodeId) const |
unsigned int | GetNumChildren () const |
bool | IsChildNode (Node *pNode) const |
int | GetChildIndex (Node *) const |
NodeId | GetId () const |
ConversationNode * | GetRoot () const |
virtual Node * | GetNext () |
void | ConnectTo (Node *pNode, unsigned int index) |
Set a connection. | |
Node * | GetConnection (unsigned int index) const |
EventType * | GetEvent (unsigned int index) const |
void | SetEvent (unsigned int index, const std::string &eventName) |
Set the event at index. | |
Static Public Member Functions | |
static Node * | Create (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. | |
Node * | m_pParent |
Parent node (may be null) | |
ConversationNode * | m_pRoot |
Root ConversationNode for the tree this node belongs to. | |
Node * | m_pConnected [MAX_CONNECTIONS] |
The nodes this oen is connected to. | |
EventType * | m_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. |
A Node is a class used as the base for all conversation tree items.
Constructor.
pParent | Nodes parent |
type | Type of this node |
text | Text for this node |
virtual LibCT::Node::~Node | ( | ) | [virtual] |
Destructor.
void LibCT::Node::AddChild | ( | Node * | pNode, |
int | index = -1 |
||
) |
Add a child to this node, will remove from old parent if needed.
pNode | Node to add |
index | Index to add node, (-1 adds to back) |
void LibCT::Node::ConnectTo | ( | Node * | pNode, |
unsigned int | index | ||
) |
Set a connection.
pNode | Node to connect to |
index | Connection index |
static Node* LibCT::Node::Create | ( | InputStream * | pInput, |
Node * | pParent | ||
) | [static] |
Serialise a node fromt the stream
void LibCT::Node::FireEvent | ( | unsigned int | index | ) | const [protected] |
Fire an event, if it exists.
index | Index of m_pEvents array to fire |
Get a child node by NodeId
Node* LibCT::Node::GetChildByIndex | ( | unsigned int | index | ) | const |
Get a child node by index
index | Index of child to return |
int LibCT::Node::GetChildIndex | ( | Node * | ) | const |
Get the index of a child node
Node* LibCT::Node::GetConnection | ( | unsigned int | index | ) | const |
Get the connected node at a specified index
index | Connection index |
EventType* LibCT::Node::GetEvent | ( | unsigned int | index | ) | const |
Get the event at index
index | Index to return |
NodeId LibCT::Node::GetId | ( | ) | const [inline] |
Get the NodeId for this node
virtual Node* LibCT::Node::GetNext | ( | ) | [virtual] |
Get active connection
Reimplemented in LibCT::ConversationNode, and LibCT::DecisionNode.
unsigned int LibCT::Node::GetNumChildren | ( | ) | const [inline] |
Get the number of children this node has
Node* LibCT::Node::GetParent | ( | ) | const [inline] |
Get the 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
std::string LibCT::Node::GetText | ( | ) | const [inline] |
Get the text of this node
NodeType LibCT::Node::GetType | ( | ) | const [inline] |
Get the type of this node
bool LibCT::Node::IsChildNode | ( | Node * | pNode | ) | const |
Test if a node is a child-node of this node
pNode | Node to test |
void LibCT::Node::RemoveChild | ( | Node * | pNode | ) |
Remove a child from this node.
pNode | Node to remove |
bool LibCT::Node::Serialise | ( | InputStream * | pInput | ) |
Serialise this node (and it's children) from a stream
bool LibCT::Node::Serialise | ( | OutputStream * | pOutput | ) |
Serialise this node (and it's children) to a stream
bool LibCT::Node::SerialiseConnections | ( | OutputStream * | pOutput | ) | [protected] |
Serialise this nodes connections (and that of it's children) to a stream
bool LibCT::Node::SerialiseConnections | ( | InputStream * | pInput | ) | [protected] |
Serialise this nodes connections (and that of it's children) from a stream
virtual bool LibCT::Node::SerialiseImpl | ( | OutputStream * | pOutput | ) | [virtual] |
Implementation of serialisation
Reimplemented in LibCT::ConversationNode, and LibCT::DecisionNode.
virtual bool LibCT::Node::SerialiseImpl | ( | InputStream * | pInput | ) | [virtual] |
Implementation of serialisation
Reimplemented in LibCT::ConversationNode, and LibCT::DecisionNode.
void LibCT::Node::SetEvent | ( | unsigned int | index, |
const std::string & | eventName | ||
) |
Set the event at index.
index | Index to set |
eventName | Name 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.
pNode | New parent node |
void LibCT::Node::SetText | ( | const std::string & | text | ) | [inline] |
Set the text of this node.
NodeList LibCT::Node::m_Children [protected] |
List of nodes that are children of this node.
NodeId LibCT::Node::m_Id [protected] |
Unique id for this node.
std::string LibCT::Node::m_ParsedText [protected] |
Parsed text of the node.
Node* LibCT::Node::m_pConnected[MAX_CONNECTIONS] [protected] |
The nodes this oen is connected to.
EventType* LibCT::Node::m_pEvents[MAX_EVENTS] [protected] |
List of events.
Node* LibCT::Node::m_pParent [protected] |
Parent node (may be null)
ConversationNode* LibCT::Node::m_pRoot [protected] |
Root ConversationNode for the tree this node belongs to.
std::string LibCT::Node::m_Text [protected] |
Text for this node.
NodeType LibCT::Node::m_Type [protected] |
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.