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

zeitgeist::ScriptServer Class Reference

The ScriptServer provides scripting facilities to the zeitgeist framework. More...

#include <scriptserver.h>

Inheritance diagram for zeitgeist::ScriptServer:

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

Collaboration graph
[legend]
List of all members.

Public Types

enum  EInitScriptType { IS_COMMON, IS_USERLOCAL }

Public Member Functions

 ScriptServer ()
 constructs the ScriptServer
virtual ~ScriptServer ()
bool Run (const std::string &fileName)
 loads and runs a ruby script, returns true on success
bool Run (boost::shared_ptr< salt::RFile > file)
 loads and runs a ruby script from an RFile
void SetInitRelPathPrefix (const std::string &relPathPrefix)
 sets the relative path prefix RunInitScript() searches for an InitScript.
bool RunInitScript (const std::string &fileName, const std::string &relPath, EInitScriptType type=IS_USERLOCAL)
 searches in ~/<mDotName>/ if dotScript is true, PREFIX/share/PACKAGE_NAME/ and <mRelPathPrefix><relPath>/ for the script <fileName>.
void SetDotName (const std::string &dotName)
 sets name of the dot directory
bool Eval (const std::string &command)
 evaluates a ruby statement, returns true on success
bool Eval (const std::string &command, GCValue &value)
 evaluates a ruby statement, returns true on success;
void UpdateCachedAllNodes ()
bool ExistsVariable (const std::string &varName)
 returns true if the variable varName exists
void CreateVariable (const std::string &varName, int value)
 creates a ruby integer variable
void CreateVariable (const std::string &varName, float value)
 creates a ruby float variable
void CreateVariable (const std::string &varName, const std::string &value)
 creates a ruby string variable
bool GetVariable (const std::string &varName, int &value)
 reads the value of a ruby integer, returns true on success
bool GetVariable (const std::string &varName, bool &value)
 reads the value of a ruby boolean, returns true on success
bool GetVariable (const std::string &varName, std::string &value)
 reads the value of a ruby string, returns true on success
bool GetVariable (const std::string &varName, float &value)
 reads the value of a ruby float, returns true on success
boost::shared_ptr< CoreContextGetContext () const
 returns the context, the ScriptServer operates in

Static Public Member Functions

static GCValue GetZeitgeistObject (boost::shared_ptr< Leaf > leaf)
 constructs the ZeitgeistObject corresponding to a given leaf

Protected Member Functions

virtual bool ConstructInternal ()
 initializes the ScriptServer and runs the default startup script 'sys/script/zeitgeist.rb', returning true on success.
bool ParseVarName (const std::string &varName, std::string &nameSpace, std::string &name)
 parses a ruby variable into a namespace and variable name part.
GCValue GetVariable (const std::string &varName)
 returns the content of a variable
bool RunInitScriptInternal (const std::string &dir, const std::string &name, bool copy, const std::string &destDir="")
 private helper function
bool GetDotDirName (std::string &dotDir)
 construct the path of the local dot directory that contains the users init scripts
bool CreateDotDir (const std::string &dotDir)
 checks if the directory <dotDir> exists and if not creates it

Protected Attributes

std::string mDotName
 the name of the users dot directory, used by RunInitScript to search for script files: ~/<mDotName>
std::string mRelPathPrefix
 the prefix RunInitScript() prepends all relativ paths

Private Member Functions

 ScriptServer (const ScriptServer &obj)
ScriptServeroperator= (const ScriptServer &obj)

Detailed Description

The ScriptServer provides scripting facilities to the zeitgeist framework.

Up to now is realized using Ruby, though the ScritpServer could easily be extended to support other script languages.

Definition at line 48 of file scriptserver.h.


Member Enumeration Documentation

enum zeitgeist::ScriptServer::EInitScriptType
 

Enumerator:
IS_COMMON 
IS_USERLOCAL 

Definition at line 54 of file scriptserver.h.


Constructor & Destructor Documentation

ScriptServer::ScriptServer  ) 
 

constructs the ScriptServer

Definition at line 227 of file scriptserver.cpp.

References deleteObject(), dirs(), getObject(), importBundle(), listObjects(), mRelPathPrefix, newObject(), popd(), pushd(), run(), selectCall(), selectObject(), and thisCall().

Here is the call graph for this function:

ScriptServer::~ScriptServer  )  [virtual]
 

Definition at line 248 of file scriptserver.cpp.

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


Member Function Documentation

bool ScriptServer::ConstructInternal  )  [protected, virtual]
 

initializes the ScriptServer and runs the default startup script 'sys/script/zeitgeist.rb', returning true on success.

Reimplemented from zeitgeist::Object.

Definition at line 451 of file scriptserver.cpp.

References zeitgeist::Object::ConstructInternal(), zeitgeist::Object::GetCore(), and gMyPrivateContext.

Here is the call graph for this function:

bool zeitgeist::ScriptServer::CreateDotDir const std::string &  dotDir  )  [protected]
 

checks if the directory <dotDir> exists and if not creates it

void zeitgeist::ScriptServer::CreateVariable const std::string &  varName,
const std::string &  value
 

creates a ruby string variable

void zeitgeist::ScriptServer::CreateVariable const std::string &  varName,
float  value
 

creates a ruby float variable

void zeitgeist::ScriptServer::CreateVariable const std::string &  varName,
int  value
 

creates a ruby integer variable

bool ScriptServer::Eval const std::string &  command,
GCValue value
 

evaluates a ruby statement, returns true on success;

Parameters:
value receives the result value if any

Definition at line 301 of file scriptserver.cpp.

References zeitgeist::RbEvalStringWrap().

Here is the call graph for this function:

bool zeitgeist::ScriptServer::Eval const std::string &  command  ) 
 

evaluates a ruby statement, returns true on success

bool zeitgeist::ScriptServer::ExistsVariable const std::string &  varName  ) 
 

returns true if the variable varName exists

boost::shared_ptr< CoreContext > ScriptServer::GetContext  )  const
 

returns the context, the ScriptServer operates in

Definition at line 445 of file scriptserver.cpp.

References gMyPrivateContext.

bool zeitgeist::ScriptServer::GetDotDirName std::string &  dotDir  )  [protected]
 

construct the path of the local dot directory that contains the users init scripts

GCValue zeitgeist::ScriptServer::GetVariable const std::string &  varName  )  [protected]
 

returns the content of a variable

bool ScriptServer::GetVariable const std::string &  varName,
float &  value
 

reads the value of a ruby float, returns true on success

Definition at line 427 of file scriptserver.cpp.

References GetVariable().

Here is the call graph for this function:

bool zeitgeist::ScriptServer::GetVariable const std::string &  varName,
std::string &  value
 

reads the value of a ruby string, returns true on success

bool zeitgeist::ScriptServer::GetVariable const std::string &  varName,
bool &  value
 

reads the value of a ruby boolean, returns true on success

bool zeitgeist::ScriptServer::GetVariable const std::string &  varName,
int &  value
 

reads the value of a ruby integer, returns true on success

Referenced by GetVariable().

GCValue ScriptServer::GetZeitgeistObject boost::shared_ptr< Leaf leaf  )  [static]
 

constructs the ZeitgeistObject corresponding to a given leaf

Definition at line 91 of file scriptserver.cpp.

References zeitgeist::RbEvalStringWrap().

Referenced by getObject(), newObject(), and selectObject().

Here is the call graph for this function:

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

bool zeitgeist::ScriptServer::ParseVarName const std::string &  varName,
std::string &  nameSpace,
std::string &  name
[protected]
 

parses a ruby variable into a namespace and variable name part.

Valid variable names are 'Namespace.Name'.

Returns:
true if a valid variable name was parsed
Parameters:
varName is the variable name to parse
nameSpace receives the namespace
name receives the variable name

bool zeitgeist::ScriptServer::Run boost::shared_ptr< salt::RFile file  ) 
 

loads and runs a ruby script from an RFile

bool zeitgeist::ScriptServer::Run const std::string &  fileName  ) 
 

loads and runs a ruby script, returns true on success

bool zeitgeist::ScriptServer::RunInitScript const std::string &  fileName,
const std::string &  relPath,
EInitScriptType  type = IS_USERLOCAL
 

searches in ~/<mDotName>/ if dotScript is true, PREFIX/share/PACKAGE_NAME/ and <mRelPathPrefix><relPath>/ for the script <fileName>.

If found the script is run and if dotScript is true copied to ~/<dotName>/. If this directory is missing it is automatically created

bool zeitgeist::ScriptServer::RunInitScriptInternal const std::string &  dir,
const std::string &  name,
bool  copy,
const std::string &  destDir = ""
[protected]
 

private helper function

void zeitgeist::ScriptServer::SetDotName const std::string &  dotName  )  [inline]
 

sets name of the dot directory

Definition at line 97 of file scriptserver.h.

References mDotName.

void ScriptServer::SetInitRelPathPrefix const std::string &  relPathPrefix  ) 
 

sets the relative path prefix RunInitScript() searches for an InitScript.

Default is '../../', suitable for all applications started from '/app'

Definition at line 463 of file scriptserver.cpp.

References mRelPathPrefix.

void ScriptServer::UpdateCachedAllNodes  ) 
 

Definition at line 253 of file scriptserver.cpp.

References zeitgeist::Object::GetCore(), and zeitgeist::Object::GetLog().

Here is the call graph for this function:


Member Data Documentation

std::string zeitgeist::ScriptServer::mDotName [protected]
 

the name of the users dot directory, used by RunInitScript to search for script files: ~/<mDotName>

Definition at line 187 of file scriptserver.h.

Referenced by SetDotName().

std::string zeitgeist::ScriptServer::mRelPathPrefix [protected]
 

the prefix RunInitScript() prepends all relativ paths

Definition at line 191 of file scriptserver.h.

Referenced by ScriptServer(), and SetInitRelPathPrefix().


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