LRAUV  revA
LuaNode Class Reference

Implements ScriptNode for the LuaAPI. More...

#include <LuaNode.h>

Inheritance diagram for LuaNode:
Collaboration diagram for LuaNode:

Public Member Functions

virtual ~LuaNode ()
 Destructor. More...
 
virtual bool hasChildNodes () const
 Returns true if the node contains child nodes. More...
 
virtual LuaNodegetNamedNode (const Str &nodeName)
 Returns the child node, by name, or NULL if none. More...
 
virtual LuaNodenewChildNode (const Str &nodeName)
 Returns a new child node than can contain other nodes. More...
 
virtual LuaNodenewChildFunction (const Str &functionName, const Str &functionBody, Logger &logger)
 Returns a new child node that is a function. More...
 
virtual int getNodeCount (const Str &nodeName) const
 Returns the number of indexed (array, or list-like) nodes Returns 0 is this is not a table. More...
 
virtual LuaNodegetIndexedNode (unsigned int index)
 Returns the indexed (array, or list-like) node at the zero-based index, or NULL if none. More...
 
virtual LuaNodegetParentNode () const
 Returns the parent node, or NULL if this is the root. More...
 
virtual int getIndex () const
 Returns the index of the node, -1 if named. More...
 
virtual const StrgetName () const
 Returns the name of the node, undefined if indexed. More...
 
virtual bool readBool (bool &readTo) const
 Sets readTo to the value of the node, as a boolean Returns true if read success. More...
 
virtual bool readDouble (double &readTo) const
 Sets readTo to the value of the node, as a double Returns true if read success. More...
 
virtual bool readString (Str &readTo) const
 Sets readTo to the value of the node, unsigned char string Returns true if read success. More...
 
virtual DataValueasNewDataValue ()
 If the node contains a dataValue, materialize such a dataValue Uses the Unit + value paradigm. More...
 
virtual bool execute (FlexArray< DataReader * > &inputs, FlexArray< SettingReader * > &settings, FlexArray< DataWriter * > &outputs, FlexArray< const Unit * > &outUnits, Logger &logger)
 Attempt to execute the function contained in this node. More...
 
virtual bool execute (FlexArray< DataReader * > &inputs, FlexArray< SettingReader * > &settings, bool &boolOutput, Logger &logger)
 Attempt to execute the function contained in this node, returning only a single boolean value. More...
 
virtual bool execute (Logger &logger)
 Attempt to execute the function contained in this node, with no inputs and no return value. More...
 
virtual Str toString () const
 Returns a string representation of this node, with its ancestors, separated by "." characters. More...
 
- Public Member Functions inherited from ScriptNode
virtual ~ScriptNode ()
 Destructor. More...
 

Private Member Functions

 LuaNode (const LuaNode &old)
 
 LuaNode ()
 Private root node constructor, available to LuaAPI too. More...
 
 LuaNode (LuaNode *parentNode, int index)
 Private "index" constructor, available to LuaAPI too. More...
 
 LuaNode (LuaNode *parentNode, const Str &name)
 Private "name" constructor, available to LuaAPI too. More...
 
bool open () const
 Open this node. More...
 
void close () const
 Close this node. More...
 
bool isRoot () const
 True if this is the root element. More...
 

Private Attributes

LuaNodeparentNode_
 Parent node. More...
 
int index_
 The index of this node. More...
 
Str name_
 The name of this node. More...
 
FastMap< const Str, LuaNode * > * childMap_
 Map of named elements. More...
 
FlexArray< LuaNode * > * childList_
 Array of numbered elements. More...
 

Friends

class LuaAPI
 

Additional Inherited Members

- Protected Member Functions inherited from ScriptNode
 ScriptNode ()
 Protected constructor for abstract base class. More...
 

Detailed Description

Implements ScriptNode for the LuaAPI.

Constructor & Destructor Documentation

LuaNode::~LuaNode ( )
virtual
LuaNode::LuaNode ( const LuaNode old)
private
LuaNode::LuaNode ( )
private

Private root node constructor, available to LuaAPI too.

Private root Node constructor.

Referenced by getIndexedNode(), and getNamedNode().

LuaNode::LuaNode ( LuaNode parentNode,
int  index 
)
private

Private "index" constructor, available to LuaAPI too.

LuaNode::LuaNode ( LuaNode parentNode,
const Str name 
)
private

Private "name" constructor, available to LuaAPI too.

Member Function Documentation

DataValue * LuaNode::asNewDataValue ( )
virtual

If the node contains a dataValue, materialize such a dataValue Uses the Unit + value paradigm.

Implements ScriptNode.

References Str::cStr(), Str::EMPTY_STR, UnitRegistry::FindUnit(), getIndexedNode(), getNamedNode(), getNodeCount(), ScriptNode::readDouble(), readDouble(), readString(), and toString().

void LuaNode::close ( void  ) const
private
bool LuaNode::execute ( FlexArray< DataReader * > &  inputs,
FlexArray< SettingReader * > &  settings,
FlexArray< DataWriter * > &  outputs,
FlexArray< const Unit * > &  outUnits,
Logger logger 
)
virtual

Attempt to execute the function contained in this node.

Implements ScriptNode.

References close(), LuaAPI::Exec(), open(), and LuaAPI::PushNil().

bool LuaNode::execute ( FlexArray< DataReader * > &  inputs,
FlexArray< SettingReader * > &  settings,
bool &  boolOutput,
Logger logger 
)
virtual

Attempt to execute the function contained in this node, returning only a single boolean value.

Implements ScriptNode.

References close(), LuaAPI::Exec(), open(), and LuaAPI::PushNil().

bool LuaNode::execute ( Logger logger)
virtual

Attempt to execute the function contained in this node, with no inputs and no return value.

Implements ScriptNode.

References close(), LuaAPI::Exec(), open(), and LuaAPI::PushNil().

virtual int LuaNode::getIndex ( ) const
inlinevirtual

Returns the index of the node, -1 if named.

Implements ScriptNode.

References index_.

LuaNode * LuaNode::getIndexedNode ( unsigned int  index)
virtual

Returns the indexed (array, or list-like) node at the zero-based index, or NULL if none.

Implements ScriptNode.

References childList_, close(), LuaAPI::CloseTableItem(), FlexArray< T >::get(), isRoot(), LuaNode(), open(), LuaAPI::OpenTableItemByIndex(), and FlexArray< T >::set().

Referenced by asNewDataValue().

virtual const Str& LuaNode::getName ( void  ) const
inlinevirtual

Returns the name of the node, undefined if indexed.

Implements ScriptNode.

References name_.

LuaNode * LuaNode::getNamedNode ( const Str nodeName)
virtual
int LuaNode::getNodeCount ( const Str nodeName) const
virtual

Returns the number of indexed (array, or list-like) nodes Returns 0 is this is not a table.

Implements ScriptNode.

References close(), LuaAPI::GetTableSize(), isRoot(), LuaAPI::IsTable(), and open().

Referenced by asNewDataValue().

LuaNode * LuaNode::getParentNode ( ) const
virtual

Returns the parent node, or NULL if this is the root.

Implements ScriptNode.

References parentNode_.

bool LuaNode::hasChildNodes ( ) const
virtual

Returns true if the node contains child nodes.

Implements ScriptNode.

References close(), isRoot(), LuaAPI::IsTable(), and open().

bool LuaNode::isRoot ( ) const
inlineprivate
LuaNode * LuaNode::newChildFunction ( const Str functionName,
const Str functionBody,
Logger logger 
)
virtual

Returns a new child node that is a function.

Implements ScriptNode.

References close(), Syslog::CRITICAL, Str::cStr(), getNamedNode(), isRoot(), LuaAPI::NewFunction(), open(), and Logger::syslog().

Referenced by LuaAPI::makeScriptFunction().

LuaNode * LuaNode::newChildNode ( const Str nodeName)
virtual

Returns a new child node than can contain other nodes.

Implements ScriptNode.

References close(), Str::cStr(), getNamedNode(), isRoot(), LuaAPI::NewTable(), and open().

Referenced by LuaAPI::makeScriptFunction().

bool LuaNode::readBool ( bool &  readTo) const
virtual

Sets readTo to the value of the node, as a boolean Returns true if read success.

Implements ScriptNode.

References close(), LuaAPI::GetBool(), isRoot(), and open().

bool LuaNode::readDouble ( double &  readTo) const
virtual

Sets readTo to the value of the node, as a double Returns true if read success.

Implements ScriptNode.

References close(), LuaAPI::GetNumber(), isRoot(), and open().

Referenced by asNewDataValue().

bool LuaNode::readString ( Str readTo) const
virtual

Sets readTo to the value of the node, unsigned char string Returns true if read success.

Implements ScriptNode.

References close(), LuaAPI::GetString(), isRoot(), and open().

Referenced by asNewDataValue().

Str LuaNode::toString ( void  ) const
virtual

Returns a string representation of this node, with its ancestors, separated by "." characters.

Implements ScriptNode.

References index_, name_, parentNode_, and toString().

Referenced by asNewDataValue(), and toString().

Friends And Related Function Documentation

friend class LuaAPI
friend

Member Data Documentation

FlexArray<LuaNode*>* LuaNode::childList_
private

Array of numbered elements.

Referenced by getIndexedNode(), and ~LuaNode().

FastMap<const Str, LuaNode*>* LuaNode::childMap_
private

Map of named elements.

Referenced by getNamedNode(), and ~LuaNode().

int LuaNode::index_
private

The index of this node.

Referenced by getIndex(), open(), and toString().

Str LuaNode::name_
private

The name of this node.

Referenced by getName(), open(), and toString().

LuaNode* LuaNode::parentNode_
private

Parent node.

Referenced by close(), getParentNode(), isRoot(), open(), and toString().


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