LibMC::MCAgent Class Reference

Wrapper class for MCAgent_t structure. More...


Public Types

enum  MC_AgentType_e
 Enum for describing the type of an agent. More...
enum  MC_AgentStatus_e
 Enum for describing the status of an agent. More...

Public Member Functions

 MCAgent ()
 Default constructor.
override string ToString ()
 Display the agent's fields.
int DeleteAgent ()
 Deletes an agent.
String GetAgentXMLString ()
 Gets the agent's XML string.
int PrintAgentCode ()
 Gets the agent's C code string.
String RetrieveAgentCode ()
 Gets the agent's C code string.
int TerminateAgent ()
 Terminates an agent.
int AclPost (MCAclMessage message)
 Posts an ACL message to the agent.
MCAclMessage AclRetrieve ()
 Retrieve an ACL message from the agent.
MCAclMessage AclWaitRetrieve ()
 Wait for and retrieve an ACL message from the agent.
int CallAgentFunc (String funcName, IntPtr retval, IntPtr varg)
 Calls a function in an agent script.
int CallAgentFunc (String funcName, ref object retval, ref object varg)
 Calls a function in an agent script.
IntPtr GetAgentExecEngine ()
 Gets an agent's Ch interpreter.
int GetAgentReturnData (int task_num, IntPtr data, IntPtr dim, IntPtr extent)
 Calls a function in an agent script.

Static Public Member Functions

static implicit operator IntPtr (MCAgent agent)
static implicit operator MCAgent (IntPtr ip)

Properties

internal IntPtr Agent [get, set]
int AgentID [get]
 Gets the agent's ID number.
String AgentName [get]
 Gets the agent's name.
int AgentNumTasks [get]
 Gets the agent's number of tasks.
MC_AgentStatus_e AgentStatus [get, set]
 Gets or sets the agent's status.
MC_AgentType_e AgentType [get]
 Gets the agent's type.
bool Valid [get]
 Checks whether the agent is valid.

Private Member Functions

internal MCAgent (IntPtr ip)
void GetAgentFields ()

Private Attributes

IntPtr agent_p
String name = ""
int id = -1
int numTasks = -1
MC_AgentStatus_e status = MC_AgentStatus_e.MC_NO_STATUS
MC_AgentType_e type = MC_AgentType_e.MC_NONE


Detailed Description

Wrapper class for MCAgent_t structure.

This class provides an interface to the Mobile-C agent structure. Member functions for the class are generally overloaded versions of the respective functions in the Mobile-C library. The class maintains a pointer to a Mobile-C agent in unmanaged memory. The pointer is not accessible by the user.

Definition at line 61 of file MCAgent.cs.


Member Enumeration Documentation

Enum for describing the type of an agent.

Note:
This enum is pulled directly from the Mobile-C library.
Enumerator:
MC_NONE  Default value to describe unininitialized agent.
MC_REMOTE_AGENT  A remote agent.
MC_LOCAL_AGENT  A local agent.
MC_RETURN_AGENT  A returning agent.

Definition at line 75 of file MCAgent.cs.

Enum for describing the status of an agent.

Note:
This enum is pulled directly from the Mobile-C library.
Enumerator:
MC_NO_STATUS  Default value for uninitialized agent
MC_WAIT_CH  Waiting to be started
MC_WAIT_MESSGSEND  Finished, waiting to migrate
MC_AGENT_ACTIVE  Running
MC_AGENT_NEUTRAL  Not running, but do not flush
MC_AGENT_SUSPENDED  Unused
MC_WAIT_FINISHED  Finished, waiting to be flushed

Definition at line 88 of file MCAgent.cs.


Constructor & Destructor Documentation

LibMC::MCAgent::MCAgent (  )  [inline]

Default constructor.

Creates an empty agent.

Definition at line 104 of file MCAgent.cs.

Referenced by operator MCAgent().

internal LibMC::MCAgent::MCAgent ( IntPtr  ip  )  [inline, private]

Definition at line 110 of file MCAgent.cs.

References Agent.


Member Function Documentation

override string LibMC::MCAgent::ToString (  )  [inline]

Display the agent's fields.

Formats an returns a string with all of the agents properties.

Returns:
A string containing a formatted representation of the agent's properties.
Note:
The agency port and any other options must be set before calling this function.

Definition at line 126 of file MCAgent.cs.

References AgentID, AgentName, AgentNumTasks, AgentStatus, and AgentType.

void LibMC::MCAgent::GetAgentFields (  )  [inline, private]

Definition at line 163 of file MCAgent.cs.

References Agent, name, numTasks, status, and type.

static implicit LibMC::MCAgent::operator IntPtr ( MCAgent  agent  )  [inline, static]

Definition at line 300 of file MCAgent.cs.

static implicit LibMC::MCAgent::operator MCAgent ( IntPtr  ip  )  [inline, static]

Definition at line 305 of file MCAgent.cs.

References MCAgent().

int LibMC::MCAgent::DeleteAgent (  )  [inline]

Deletes an agent.

Deletes an agent from the agency.

Returns:
The return value of the underlying MC_DeleteAgent function call.

Definition at line 322 of file MCAgent.cs.

References Agent.

String LibMC::MCAgent::GetAgentXMLString (  )  [inline]

Gets the agent's XML string.

Returns the full XML string associated with the agent.

Returns:
The return value of the underlying MC_GetAgentXMLString function call.

Definition at line 335 of file MCAgent.cs.

References Agent.

int LibMC::MCAgent::PrintAgentCode (  )  [inline]

Gets the agent's C code string.

Prints the C code associated with the agent to stdout.

Returns:
The return value of the underlying MC_PrintAgentCode function call.

Definition at line 348 of file MCAgent.cs.

References Agent.

String LibMC::MCAgent::RetrieveAgentCode (  )  [inline]

Gets the agent's C code string.

Returns the C code associated with the agent.

Returns:
A string containing the agent's C code.

Definition at line 360 of file MCAgent.cs.

References Agent.

int LibMC::MCAgent::TerminateAgent (  )  [inline]

Terminates an agent.

Terminates an agent regardless of the agent's state.

Returns:
The return value of the underlying MC_TerminateAgent function call.

Definition at line 373 of file MCAgent.cs.

References Agent.

int LibMC::MCAgent::AclPost ( MCAclMessage  message  )  [inline]

Posts an ACL message to the agent.

Delivers an ACL message to the agent.

Parameters:
message The ACL message object to deliver.
Returns:
The return value of the underlying MC_AclPost function call.
Note:
The message must be a valid message or this function call will fail.

Definition at line 398 of file MCAgent.cs.

References LibMC::MCAclMessage::AclMsg, and Agent.

MCAclMessage LibMC::MCAgent::AclRetrieve (  )  [inline]

Retrieve an ACL message from the agent.

Retrieves an ACL message from the agent if one is available.

Returns:
The ACL message or a blank ACL message if one was not available.
Note:
The message must be a valid message or this function call will fail.

Definition at line 414 of file MCAgent.cs.

References Agent.

MCAclMessage LibMC::MCAgent::AclWaitRetrieve (  )  [inline]

Wait for and retrieve an ACL message from the agent.

Retrieves an ACL message from the agent when one becomes available.

Returns:
The ACL message or a blank ACL message if the call fails.
Note:
This function call blocks.

Definition at line 433 of file MCAgent.cs.

References Agent.

int LibMC::MCAgent::CallAgentFunc ( String  funcName,
IntPtr  retval,
IntPtr  varg 
) [inline]

Calls a function in an agent script.

Calls a function in an agent's script file. This function requires manual marshaling by the user.

Parameters:
funcName The name of the function to call
retval A pointer to memory for the return value
varg A pointer to the argument for the function
Returns:
The return value of the underlying MC_CallAgentFunc function call.
Note:
BE VERY CAREFUL! You must marshal your arguments! If possible, use the other CallAgentFunc that handles marshaling automatically.
See also:
Overloaded CallAgentFunc, LibMCConsole example

Definition at line 459 of file MCAgent.cs.

References Agent.

Referenced by CallAgentFunc().

int LibMC::MCAgent::CallAgentFunc ( String  funcName,
ref object  retval,
ref object  varg 
) [inline]

Calls a function in an agent script.

Calls a function in an agent's script file. This function requires boxing of parameters, but no marshaling.

Parameters:
funcName The name of the function to call
retval A boxed object to hold the return value
varg The boxed argument to the agent function
Returns:
The return value of the underlying MC_CallAgentFunc function call.
Note:
This function handles marshaling of the argument and return value. The memory provided to the agent function for both retval and varg is not preserved after this function call! If the memory is to be kept by the agent, use the manually marshaled version of this function. Also note that even though structures can be marshaled automatically, in this function, the type of the structure is unknown and therefore it must be handled manually, even though the marshaling is transparent to the user.
See also:
Overloaded CallAgentFunc, LibMCConsole example

Definition at line 489 of file MCAgent.cs.

References CallAgentFunc().

IntPtr LibMC::MCAgent::GetAgentExecEngine (  )  [inline]

Gets an agent's Ch interpreter.

Gets a pointer to the agent's Ch interpreter. Will be improved shortly.

Returns:
A pointer to the Ch interpreter.
Note:
Nothing in the LibMC.NET library can make use of the Ch interpreter yet.
Todo:
Wrap MC_GetAgentExecEngine with an object for the void* pointer return type (Ch interpreter).

Definition at line 534 of file MCAgent.cs.

References Agent.

int LibMC::MCAgent::GetAgentReturnData ( int  task_num,
IntPtr  data,
IntPtr  dim,
IntPtr  extent 
) [inline]

Calls a function in an agent script.

Calls a function in an agent's script file. This function requires manual marshaling by the user.

Parameters:
task_num Task number to get data from
data A pointer to memory for the data
dim A pointer to hold the dimensions of the data
extent A pointer to hold the dimensions of the data
Returns:
The return value of the underlying MC_GetAgentReturnData function call.
Note:
This function does nothing but throw an exception right now.
Todo:
Implement GetAgentReturnData

Definition at line 555 of file MCAgent.cs.


Field Documentation

IntPtr LibMC::MCAgent::agent_p [private]

Definition at line 63 of file MCAgent.cs.

String LibMC::MCAgent::name = "" [private]

Definition at line 64 of file MCAgent.cs.

Referenced by GetAgentFields().

int LibMC::MCAgent::id = -1 [private]

Definition at line 65 of file MCAgent.cs.

int LibMC::MCAgent::numTasks = -1 [private]

Definition at line 66 of file MCAgent.cs.

Referenced by GetAgentFields().

MC_AgentStatus_e LibMC::MCAgent::status = MC_AgentStatus_e.MC_NO_STATUS [private]

Definition at line 67 of file MCAgent.cs.

Referenced by GetAgentFields().

MC_AgentType_e LibMC::MCAgent::type = MC_AgentType_e.MC_NONE [private]

Definition at line 68 of file MCAgent.cs.

Referenced by GetAgentFields().


Property Documentation

internal IntPtr LibMC::MCAgent::Agent [get, set, private]

int LibMC::MCAgent::AgentID [get]

Gets the agent's ID number.

Gets the agent's ID number as assigned by Mobile-C if the agent is a valid agent.

Returns:
The agent's ID number or -1 for an empty agent.

Definition at line 181 of file MCAgent.cs.

Referenced by ToString().

String LibMC::MCAgent::AgentName [get]

Gets the agent's name.

Gets the agent's name as assigned by Mobile-C or the agent script if the agent is a valid agent.

Returns:
The agent's name or an empty string for an empty agent.

Definition at line 201 of file MCAgent.cs.

Referenced by ToString().

int LibMC::MCAgent::AgentNumTasks [get]

Gets the agent's number of tasks.

Gets the agent's ID number of tasks if the agent is a valid agent.

Returns:
The agent's ID number of tasks or -1 for an empty agent.

Definition at line 220 of file MCAgent.cs.

Referenced by ToString().

MC_AgentStatus_e LibMC::MCAgent::AgentStatus [get, set]

Gets or sets the agent's status.

Gets or sets the agent's status. When setting the status, the status is double-checked after setting it and may not be set depending on the state of the agent and the agency.

Returns:
The agent's status or MC_NO_STATUS for an empty agent.

Definition at line 242 of file MCAgent.cs.

Referenced by ToString().

MC_AgentType_e LibMC::MCAgent::AgentType [get]

Gets the agent's type.

Gets the agent's type.

Returns:
The agent's type or MC_NONE for an empty agent.

Definition at line 264 of file MCAgent.cs.

Referenced by ToString().

bool LibMC::MCAgent::Valid [get]

Checks whether the agent is valid.

Checks the internal agent pointer to see if it is non-zero.

Returns:
True if the pointer is valid, false otherwise

Definition at line 286 of file MCAgent.cs.


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

Generated on Thu Nov 13 14:22:59 2008 for Mobile-C by  doxygen 1.5.5