newspeoplefor developersdocumentationdownloads

nScriptServer Class Reference
[Scripting Support]

#include <nscriptserver.h>

Inheritance diagram for nScriptServer:

nRoot nObject nNode nReferenced nSignalEmitter nBinScriptServer nLuaServer nPythonServer nRubyServer nTclServer List of all members.

Detailed Description

The script server object is the communication point between a nRoot object's Dispatch() method and a specific scripting language. More specifically, the script server's main task is to translate nCmd objects into script statements and back, and to communicate with receiver nRoot objects by sending nCmd objects to them (which is done by invoking Dispatch() on the receiver with the nCmd object as the argument).

Script servers are also used as filter for the object serialization. An object serializes itself by emitting nCmd objects to the file server. The file server will talk to a script server to translate those nCmd objects to actual script statements, which are then written to the output stream. This stream must then simply be fed into a script server to reconstruct the serialized object, no special loader code is needed.

(C) 2002 RadonLabs GmbH

Definition at line 31 of file nscriptserver.h.


Public Types

enum  SelectMethod {
  SELCOMMAND,
  NOSELCOMMAND
}

Public Member Functions

 nScriptServer ()
 constructor
virtual ~nScriptServer ()
 destructor
virtual bool Run (const char *cmdStr, nString &result)
 evaluate a script command
virtual bool RunFunction (const char *functionName, nString &result)
 invoke a script function by name, with no parameters
virtual bool RunScript (const char *filename, nString &result)
 evaluate a script file
virtual nFileBeginWrite (const char *filename, nObject *obj)
 write header of a persistent object file
virtual bool WriteBeginNewObject (nFile *fp, nRoot *o, nRoot *owner)
 write object header with default constructor
virtual bool WriteBeginNewObjectCmd (nFile *fp, nRoot *o, nRoot *owner, nCmd *cmd)
 write object header with constructor cmd
virtual bool WriteBeginSelObject (nFile *fp, nRoot *o, nRoot *owner)
 write object header without constructor (select only)
virtual bool WriteCmd (nFile *, nCmd *)
 translate and write a cmd message
virtual bool WriteEndObject (nFile *fp, nRoot *o, nRoot *owner)
 write object footer
virtual bool EndWrite (nFile *)
 finish a persistent object file
void SetFailOnError (bool b)
 abort program on error?
bool GetFailOnError () const
 get abort program status
void SetSelectMethod (SelectMethod sm)
 set the select method when writing persistent objects
SelectMethod GetSelectMethod () const
 get current select method
void SetQuitRequested (bool b)
 set the quit requested flag
bool GetQuitRequested () const
 get the quit requested flag
virtual bool Trigger ()
 trigger server (should be called frequently)
virtual nString Prompt ()
 generate a prompt string for interactive mode

Static Public Member Functions

static void SetCurrentTargetObject (nObject *obj)
 set an unnamed object that will receive cmds instead of the cwd
static nObjectGetCurrentTargetObject ()
 get the currently set unnamed object

Static Protected Attributes

static nObjectcurrentTargetObject = 0
 when set the script server will dispatch cmds to this object instead of the cwd

Member Enumeration Documentation

enum nScriptServer::SelectMethod
 

Enumerator:
SELCOMMAND 
NOSELCOMMAND 

Definition at line 35 of file nscriptserver.h.


Constructor & Destructor Documentation

nScriptServer::nScriptServer  ) 
 

constructor

Definition at line 15 of file nscriptserver_main.cc.

nScriptServer::~nScriptServer  )  [virtual]
 

destructor

Definition at line 26 of file nscriptserver_main.cc.


Member Function Documentation

bool nScriptServer::Run const char *  cmdStr,
nString result
[virtual]
 

evaluate a script command

Run a script statement.

Parameters:
cmdStr the statement to execute
result [out] will be filled with the result
Returns:
false if an error occurred during execution

Reimplemented in nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 40 of file nscriptserver_main.cc.

bool nScriptServer::RunFunction const char *  functionName,
nString result
[virtual]
 

invoke a script function by name, with no parameters

Run a script function with the specified name without any args

Parameters:
functionName the function to invoke
result [out] will be filled with the result
Returns:
false if an error occurred during execution

Reimplemented in nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 55 of file nscriptserver_main.cc.

bool nScriptServer::RunScript const char *  filename,
nString result
[virtual]
 

evaluate a script file

Run a script file.

Parameters:
filename the script filename (ABSOLUTE PATH!)
result [out] will be filled with the result
Returns:
false if an error occurred during execution

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 70 of file nscriptserver_main.cc.

void nScriptServer::SetCurrentTargetObject nObject obj  )  [inline, static]
 

set an unnamed object that will receive cmds instead of the cwd

Definition at line 165 of file nscriptserver.h.

nObject * nScriptServer::GetCurrentTargetObject  )  [inline, static]
 

get the currently set unnamed object

Definition at line 175 of file nscriptserver.h.

nFile * nScriptServer::BeginWrite const char *  filename,
nObject obj
[virtual]
 

write header of a persistent object file

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 92 of file nscriptserver_main.cc.

bool nScriptServer::WriteBeginNewObject nFile fp,
nRoot o,
nRoot owner
[virtual]
 

write object header with default constructor

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 102 of file nscriptserver_main.cc.

bool nScriptServer::WriteBeginNewObjectCmd nFile fp,
nRoot o,
nRoot owner,
nCmd cmd
[virtual]
 

write object header with constructor cmd

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 112 of file nscriptserver_main.cc.

bool nScriptServer::WriteBeginSelObject nFile fp,
nRoot o,
nRoot owner
[virtual]
 

write object header without constructor (select only)

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 122 of file nscriptserver_main.cc.

bool nScriptServer::WriteCmd nFile ,
nCmd
[virtual]
 

translate and write a cmd message

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 132 of file nscriptserver_main.cc.

bool nScriptServer::WriteEndObject nFile fp,
nRoot o,
nRoot owner
[virtual]
 

write object footer

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 142 of file nscriptserver_main.cc.

bool nScriptServer::EndWrite nFile  )  [virtual]
 

finish a persistent object file

Reimplemented in nBinScriptServer, nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 152 of file nscriptserver_main.cc.

void nScriptServer::SetFailOnError bool  b  )  [inline]
 

abort program on error?

Definition at line 125 of file nscriptserver.h.

bool nScriptServer::GetFailOnError  )  const [inline]
 

get abort program status

Definition at line 135 of file nscriptserver.h.

void nScriptServer::SetSelectMethod SelectMethod  sm  ) 
 

set the select method when writing persistent objects

nScriptServer::SelectMethod nScriptServer::GetSelectMethod  )  const [inline]
 

get current select method

Definition at line 155 of file nscriptserver.h.

void nScriptServer::SetQuitRequested bool  b  )  [inline]
 

set the quit requested flag

Definition at line 105 of file nscriptserver.h.

bool nScriptServer::GetQuitRequested  )  const [inline]
 

get the quit requested flag

Definition at line 115 of file nscriptserver.h.

bool nScriptServer::Trigger void   )  [virtual]
 

trigger server (should be called frequently)

This method should be called frequently (normally once per frame) when the script server is not run in interactive mode.

  • 21-Dec-98 floh created
  • 31-Aug-99 floh 'quit_requested' wird zurueckgesetzt, wenn es einmal true war

Reimplemented in nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 168 of file nscriptserver_main.cc.

nString nScriptServer::Prompt  )  [virtual]
 

generate a prompt string for interactive mode

Reimplemented in nTclServer, nLuaServer, nPythonServer, and nRubyServer.

Definition at line 81 of file nscriptserver_main.cc.


Member Data Documentation

nObject * nScriptServer::currentTargetObject = 0 [static, protected]
 

when set the script server will dispatch cmds to this object instead of the cwd

Definition at line 10 of file nscriptserver_main.cc.


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

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.