My Project
Public Member Functions | List of all members
NPL::CNPL_imp Class Reference

implementation of INPL More...

#include <NPL_imp.h>

Inheritance diagram for NPL::CNPL_imp:
NPL::INPL ParaEngine::BaseInterface

Public Member Functions

virtual INPLRuntimeGetNPLRuntime ()
 the core NPL runtime interface. More...
 
virtual int activate (const char *sNPLFilename, const char *sCode, int nCodeLength)
 [thread safe] activate the specified file. More...
 
virtual int StartService (const char *pCommandLine)
 start the NPL service. More...
 
virtual void StopService ()
 stop the NPL service. More...
 
virtual void FrameMove (float fElapsedTime)
 desc: Move all object's mental states to next time the following global states are defined specific to this simulator (1) for all NPC type object, "npc_name = object.identifer();" is passed to the neuron file as input. More...
 
virtual void SetGameLoop (const char *scriptName)
 reset the game loop script. More...
 
virtual void SetGameLoopInterval (float fInterval)
 set the game loop activation interval. More...
 
virtual void AddNPLCommand (const char *sCommand, int nLength=0)
 add an NPL command code to the (main state's) pending list to be processed in the next frame move cycle. More...
 

Detailed Description

implementation of INPL

Member Function Documentation

§ activate()

int CNPL_imp::activate ( const char *  sNPLFilename,
const char *  sCode,
int  nCodeLength 
)
virtual

[thread safe] activate the specified file.

It can either be local or remote file.

Parameters
pStatethe source runtime state that initiated this activation. If pState is NULL, the main runtime state is used.
sNPLFileNamea globally unique name of a NPL file name instance. The string format of an NPL file name is like below. [(sRuntimeStateName|gl)][sNID:]sRelativePath[]

the following is a list of all valid file name combinations: "user001@paraengine.com:script/hello.lua" – a file of user001 in its default gaming thread "(world1)server001@paraengine.com:script/hello.lua" – a file of server001 in its thread world1 "(worker1)script/hello.lua" – a local file in the thread worker1 "(gl)script/hello.lua" – a glia (local) file in the current runtime state's thread "script/hello.lua" – a file in the current thread. For a single threaded application, this is usually enough. "(worker1)NPLRouter.dll" – activate a C++ or C# dll. Please note that, in windows, it looks for NPLRonter.dll; in linux, it looks for ./libNPLRouter.so "plugin/libNPLRouter.dll" – almost same as above, it is recommented to remove the heading 'lib' when loading. In windows, it looks for plugin/NPLRonter.dll; in linux, it looks for ./plugin/libNPLRouter.so

Parameters
sCodeit is a chunk of pure data table init code that would be transmitted to the destination file.
Note
: pure data table is defined as table consisting of only string, number and other table of the above type. NPL.activate function also accepts ParaFileObject typed message data type. ParaFileObject will be converted to base64 string upon transmission. There are size limit though of 10MB. one can also programmatically check whether a script object is pure date by calling NPL.SerializeToSCode() function. Please note that data types that is not pure data in sCode will be ignored instead of reporting an error.
Returns
: NPLReturnCode. 0 means succeed.

Implements NPL::INPL.

§ AddNPLCommand()

void CNPL_imp::AddNPLCommand ( const char *  sCommand,
int  nLength = 0 
)
virtual

add an NPL command code to the (main state's) pending list to be processed in the next frame move cycle.

[thread safe] This function is thread-safe by using a mutex internally.

Parameters
sCommandcommand to call in the next frame move.
nLengthlength in bytes. if 0, we will calculate from the sCommand.

Implements NPL::INPL.

§ FrameMove()

void CNPL_imp::FrameMove ( float  fElapsedTime)
virtual

desc: Move all object's mental states to next time the following global states are defined specific to this simulator (1) for all NPC type object, "npc_name = object.identifer();" is passed to the neuron file as input.

(1.1) for all OPC type object, "opc_name = object.identifer();" is passed to the neuron file as input. (2) for GUI sensor type object, "sensor_name = object.identifer();" is passed to the neuron file as input. (2.1) for GUI sensor type object that accept key strokes, an additional "keystring = keystrings" is passed as input.

– execute NPL network logic for one pass

Implements NPL::INPL.

§ GetNPLRuntime()

INPLRuntime * CNPL_imp::GetNPLRuntime ( )
virtual

the core NPL runtime interface.

change global settings of the NPL runtime as well as managing runtime state.

Implements NPL::INPL.

§ SetGameLoop()

void CNPL_imp::SetGameLoop ( const char *  scriptName)
virtual

reset the game loop script.

the game loop script will be activated every 0.5 seconds see SetGameLoopInterval() to change the default interval Please keep the game loop concise. The default game loop is ./script/gameinterface.lua

Implements NPL::INPL.

§ SetGameLoopInterval()

void CNPL_imp::SetGameLoopInterval ( float  fInterval)
virtual

set the game loop activation interval.

The default value is 0.5 seconds.

Implements NPL::INPL.

§ StartService()

int CNPL_imp::StartService ( const char *  pCommandLine)
virtual

start the NPL service.

This function does not return until finished. we may call it inside the main function of an exe or in a different thread.

Parameters
pCommandLinee.g. "bootstrapper=\"config/bootstrapper_emptyshell.xml""

Implements NPL::INPL.

§ StopService()

void CNPL_imp::StopService ( )
virtual

stop the NPL service.

Sending the stop signal. It does not return until service is stopped.

Implements NPL::INPL.


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