My Project
Public Member Functions | Protected Attributes | List of all members
NPL::CAutoUpdaterClient Class Reference

CAutoUpdaterClietn also implements a dummy INPL Runtime state, so that it can receive call back from the autoupdater.dll activation. More...

#include <AutoUpdaterClient.h>

Inheritance diagram for NPL::CAutoUpdaterClient:
NPL::INPLRuntimeState NPL::IAutoUpdaterClient

Public Member Functions

virtual void SetUpdaterDllPath (const char *sDllPath=NULL)
 set the autoupdater.dll file path More...
 
virtual void ActivateAutoUpdater (const std::string &sMsg)
 call the auto updater. More...
 
virtual int BeginUpdate (const std::string &curVersion, const char *sUpdaterName=NULL)
 begin updating the application. More...
 
virtual void OnProgress (AutoUpdaterProgress eventType, const char *msg=NULL, int finishcount=0, int allcount=0)
 on progress
 
virtual void OnMessageCallback (NPLInterface::NPLObjectProxy &msg)
 this function is called whenever we receive a message. More...
 
virtual AutoUpdaterProgress WaitForCompletion (IAutoUpdaterCallback *pCallback=0)
 this function returns until auto updater is finished. More...
 
virtual bool GetUpdaterMessage (ProgressMessage &msg)
 Get a progress message from the queue. More...
 
virtual bool PeekUpdaterMessage (ProgressMessage &msg)
 Peek a progress message from the queue. More...
 
virtual void ExitUpdater ()
 join all threads and unload dll. More...
 
virtual void ApplyPatch ()
 apply the recently downloaded patch
 
virtual const std::string & GetName () const
 return the name of this runtime state. More...
 
virtual int activate (const char *sNPLFilename, const char *sCode, int nCodeLength=0, int priority=2, int reliability=4)
 activate the specified file. More...
 
virtual NPLReturnCode Activate_async (const std::string &filepath, const char *code=NULL, int nLength=0, int priority=0)
 activate the specified file in this runtime state. More...
 
virtual NPLReturnCode ActivateLocal (const char *filepath, const char *code=NULL, int nLength=0, int priority=0)
 same as Activate_async, except that it is a short cut name. More...
 
virtual NPLReturnCode Activate_async (NPLMessage_ptr &msg, int priority=0)
 same as Activate_async. More...
 
virtual NPLReturnCode SendMessage (NPLMessage_ptr &msg, int priority=0)
 send a message to the current message queue. More...
 
virtual const char * GetCurrentMsg ()
 get a pointer to the current message
 
virtual int GetCurrentMsgLength ()
 get length of the current message
 
virtual INPLRuntimeGetNPLRuntime ()
 get the NPL runtime environment
 
virtual void WriteLog (const char *text, int nTextLen=0, int nLogType=0)
 write a log message More...
 
virtual bool SetTimer (int nIDEvent, float fElapse, const char *sNeuronFile)
 creates a timer with the specified time-out value [thread safe] More...
 
virtual bool KillTimer (int nIDEvent)
 Destroys the specified timer [thread safe]. More...
 
virtual bool ChangeTimer (int nIDEvent, int dueTime, int period)
 Changes the start time and the interval between method invocations for a timer, using 32-bit signed integers to measure time intervals. More...
 
virtual void SetUpdateUrl (const std::string &updateurl)
 set the update url. More...
 
virtual void RegisterFile (const char *sFilename, INPLActivationFile *pFileHandler=NULL)
 function to register the a file handler in the current NPL state, so that it is callable from NPL script or C++ More...
 
virtual void call (const char *sNPLFilename, const char *sCode, int nCodeLength=0)
 synchronous function call
 
- Public Member Functions inherited from NPL::IAutoUpdaterClient
virtual void OnProgress (AutoUpdaterProgress eventType, const char *msg=NULL, int finishcount=0, int allcount=0)=0
 This function is called for update progress.
 

Protected Attributes

const char * m_current_msg
 pointer to the current message. More...
 
int m_current_msg_length
 length of the current message. More...
 
std::string m_name
 the name of this runtime state. More...
 
std::string m_updateurl
 get update url
 
ParaEngine::CPluginLoader m_auto_updater_plugin
 the Auto updater plugin
 
AutoUpdaterProgress m_progress_status
 
ParaEngine::Mutex m_mutex
 
ParaEngine::Semaphore m_semaphore
 
std::queue< ProgressMessagem_msgs
 all messages
 
std::string m_session_dir
 the directory where the downloaded core update files are cached. More...
 
std::string m_sApplyPatchMsg
 apply patch message
 
std::string m_updater_plugin_path
 autoupdater.dll file path. More...
 
IAutoUpdaterCallbackm_pUpdaterCallback
 

Additional Inherited Members

- Public Types inherited from NPL::IAutoUpdaterClient
enum  AutoUpdaterProgress {
  AUP_NOT_STARTED, AUP_STARTED, AUP_NOCHANGE, AUP_UNKNOWN,
  AUP_BROKENFILE, AUP_ERROR, AUP_PROGRESS, AUP_COMPLETED,
  AUP_DO_APPLY_PATCH
}
 auto update progress
 

Detailed Description

CAutoUpdaterClietn also implements a dummy INPL Runtime state, so that it can receive call back from the autoupdater.dll activation.

Member Function Documentation

§ activate()

int CAutoUpdaterClient::activate ( const char *  sNPLFilename,
const char *  sCode,
int  nCodeLength = 0,
int  priority = 2,
int  reliability = 4 
)
virtual

activate the specified file.

It can either be local or remote file.

Implements NPL::INPLRuntimeState.

§ Activate_async() [1/2]

NPL::NPLReturnCode CAutoUpdaterClient::Activate_async ( const std::string &  filepath,
const char *  code = NULL,
int  nLength = 0,
int  priority = 0 
)
virtual

activate the specified file in this runtime state.

the file can be script or DLL. The function will just insert the message into the message queue and return immediately.

Parameters
codeit is a chunk of code that should be executed in the destination neuron. this code usually set the values of POL global variables.
nLengththe code length. if this is 0, length is determined from code, however, it must not exceed 4096 bytes. if it is specified. it can be any code length
prioritybigger is higher. 0 is the default. if 1, it will be inserted to the front of the queue.
Returns
: NPLReturnCode

Implements NPL::INPLRuntimeState.

§ Activate_async() [2/2]

NPL::NPLReturnCode CAutoUpdaterClient::Activate_async ( NPLMessage_ptr &  msg,
int  priority = 0 
)
virtual

same as Activate_async.

except that input are read from NPLMesage. e.g. NPLMessage_ptr msg(new NPLMessage()); return Activate_async(msg, priority);

Parameters
msgthe caller is should only new but never delete the NPLMessage_ptr. And that the message must be created in the same thread, usually just before calling this function

Implements NPL::INPLRuntimeState.

§ ActivateAutoUpdater()

void CAutoUpdaterClient::ActivateAutoUpdater ( const std::string &  sMsg)
virtual

call the auto updater.

Implements NPL::IAutoUpdaterClient.

§ ActivateLocal()

NPL::NPLReturnCode CAutoUpdaterClient::ActivateLocal ( const char *  filepath,
const char *  code = NULL,
int  nLength = 0,
int  priority = 0 
)
virtual

same as Activate_async, except that it is a short cut name.

and may be used by external dlls to activate a file on this local state asynchrounously.

Implements NPL::INPLRuntimeState.

§ BeginUpdate()

int CAutoUpdaterClient::BeginUpdate ( const std::string &  curVersion,
const char *  sUpdaterName = NULL 
)
virtual

begin updating the application.

Returns
: S_OK, update succeed, E_FAIL autoupdater.dll is not loaded.

Implements NPL::IAutoUpdaterClient.

§ ChangeTimer()

virtual bool NPL::CAutoUpdaterClient::ChangeTimer ( int  nIDEvent,
int  dueTime,
int  period 
)
inlinevirtual

Changes the start time and the interval between method invocations for a timer, using 32-bit signed integers to measure time intervals.

[thread safe]

Parameters
nIDEventSpecifies the timer to be destroyed.For nIDEvent<=0, they are reserved for internal uses can not be killed by this function. This value must be the same as the nIDEvent value passed to the SetTimer function that created the timer.
dueTimeThe amount of time to delay before the invoking the callback method specified when the Timer was constructed, in milliseconds. Specify zero (0) to restart the timer immediately. however, the current implementation does not accept dueTime that is larger than MAX_TIMER_DUE_TIME 10000000, which is 10000 seconds.
period:Thetime interval between invocations of the callback method specified when the Timer was constructed, in milliseconds.
Returns
: If the function succeeds, the return value is true

Implements NPL::INPLRuntimeState.

§ ExitUpdater()

void NPL::CAutoUpdaterClient::ExitUpdater ( )
virtual

join all threads and unload dll.

This function is automatically called when the interface is cleaned up.

Implements NPL::IAutoUpdaterClient.

§ GetName()

const std::string & CAutoUpdaterClient::GetName ( ) const
virtual

return the name of this runtime state.

if "", it is considered an anonymous name

Implements NPL::INPLRuntimeState.

§ GetUpdaterMessage()

bool NPL::CAutoUpdaterClient::GetUpdaterMessage ( ProgressMessage msg)
virtual

Get a progress message from the queue.

This function will block until a message arrive, much like the Win32 API.

Implements NPL::IAutoUpdaterClient.

§ KillTimer()

virtual bool NPL::CAutoUpdaterClient::KillTimer ( int  nIDEvent)
inlinevirtual

Destroys the specified timer [thread safe].

Parameters
nIDEventSpecifies the timer to be destroyed.For nIDEvent<=0, they are reserved for internal uses can not be killed by this function. This value must be the same as the nIDEvent value passed to the SetTimer function that created the timer.
Returns
: If the function succeeds, the return value is true

Implements NPL::INPLRuntimeState.

§ OnMessageCallback()

void CAutoUpdaterClient::OnMessageCallback ( NPLInterface::NPLObjectProxy msg)
virtual

this function is called whenever we receive a message.

Implements NPL::IAutoUpdaterClient.

§ PeekUpdaterMessage()

bool NPL::CAutoUpdaterClient::PeekUpdaterMessage ( ProgressMessage msg)
virtual

Peek a progress message from the queue.

This function will return false if there is no message in the queue, much like the Win32 API.

Implements NPL::IAutoUpdaterClient.

§ RegisterFile()

void NPL::CAutoUpdaterClient::RegisterFile ( const char *  sFilename,
INPLActivationFile pFileHandler = NULL 
)
virtual

function to register the a file handler in the current NPL state, so that it is callable from NPL script or C++

Parameters
sFilenameany name with cpp file extension can be used. usually it is "states.cpp". The name does not need to be same as the real cpp file.
pFileHandlerif NULL it will unregister. If not, it is the file handler pointer, the pointer must be always valid, it is usually a static singleton object.

Implements NPL::INPLRuntimeState.

§ SendMessage()

NPL::NPLReturnCode CAutoUpdaterClient::SendMessage ( NPLMessage_ptr &  msg,
int  priority = 0 
)
virtual

send a message to the current message queue.

This function is rarely needed to call directly, use Activate_async instead. e.g. NPLMessage_ptr msg(new NPLMessage()); return SendMessage(msg, priority);

Parameters
msgthe message to send. Please note that when the function returns, the msg will be reset to null.
Returns
may fail if message queue is full.

Implements NPL::INPLRuntimeState.

§ SetTimer()

virtual bool NPL::CAutoUpdaterClient::SetTimer ( int  nIDEvent,
float  fElapse,
const char *  sNeuronFile 
)
inlinevirtual

creates a timer with the specified time-out value [thread safe]

Parameters
nIDEventSpecifies a positive timer identifier. For nIDEvent<=0, they are reserved for internal uses. If the NPL runtime already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset.
fElapseSpecifies the time-out value, in seconds. Please note that a timer will not be repeatedly activated if its timeout is shorter than the frame rate of the NPL simulation pipeline .
sNeuronFileThe NPL file to be activated when the time-out value elapses. For more information about the file name See NPL.activate().
Returns
: true if succeeds.An application can pass the value of the nIDEvent parameter to the NPL.KillTimer function to destroy the timer.

Implements NPL::INPLRuntimeState.

§ SetUpdaterDllPath()

void NPL::CAutoUpdaterClient::SetUpdaterDllPath ( const char *  sDllPath = NULL)
virtual

set the autoupdater.dll file path

Parameters
sDllPathif not set, it will default to "AutoUpdater.dll" in the current working directory.

Implements NPL::IAutoUpdaterClient.

§ SetUpdateUrl()

void NPL::CAutoUpdaterClient::SetUpdateUrl ( const std::string &  updateurl)
virtual

set the update url.

§ WaitForCompletion()

NPL::CAutoUpdaterClient::AutoUpdaterProgress NPL::CAutoUpdaterClient::WaitForCompletion ( IAutoUpdaterCallback pCallback = 0)
virtual

this function returns until auto updater is finished.

Implements NPL::IAutoUpdaterClient.

§ WriteLog()

void CAutoUpdaterClient::WriteLog ( const char *  text,
int  nTextLen = 0,
int  nLogType = 0 
)
virtual

write a log message

Parameters
textthe content of the log message.
nTextLenthe log text length in byte. if 0, text length will be determined automatically.
nLogTypeif this is 0, it is a normal log message. if this is 1, we will print current time, and runtime state name with the log message.

Implements NPL::INPLRuntimeState.

Member Data Documentation

§ m_current_msg

const char* NPL::CAutoUpdaterClient::m_current_msg
protected

pointer to the current message.

it is only valid during activation call. NULL will be returned

§ m_current_msg_length

int NPL::CAutoUpdaterClient::m_current_msg_length
protected

length of the current message.

it is only valid during activation call.

§ m_name

std::string NPL::CAutoUpdaterClient::m_name
protected

the name of this runtime state.

if "", it is considered an anonymous name

§ m_session_dir

std::string NPL::CAutoUpdaterClient::m_session_dir
protected

the directory where the downloaded core update files are cached.

§ m_updater_plugin_path

std::string NPL::CAutoUpdaterClient::m_updater_plugin_path
protected

autoupdater.dll file path.


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