Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CResource Class Reference

CResource. More...

#include <Resource.h>

List of all members.

Public Member Functions

 CResource ()
 CResource.
 ~CResource ()
 ~CResource
void Create (CNetworkPlayer *)
 Create.
void Process ()
 Process.
void SetHost (uint32 port)
 SetHost.
void SetClient (const CResource *pHostResource)
 SetClient.
bool AddParticipant (CParticipant *pParticipant)
 AddParticipant.
void GetParticipants (vector< CParticipant * > &parts) const
 GetParticipants.
void GetParticipantCount (uint32 &Humans, uint32 &AIs) const
 GetParticipantCount.
uint32 GetParticipantCount () const
 GetParticipantCount.
void ResetResource (bool bKillImmobile)
 ResetResource.
void UpdateBenchmark ()
 UpdateBenchmark.
uint64 GetBenchmark () const
 GetBenchmark.
bool operator< (const CResource other) const
 operator <
void SendMessage (CMessage *pMsg) const
 SendMessage.
bool IsMsgAvail () const
 IsMsgAvail.
CMessageGetMessage () const
 GetMessage.
const CDescriptionGetDescription () const
 GetDescription.
int8 * GetAddress (int8 *buffer) const
 GetAddress.
uint32 GetAvgPing () const
 GetAvgPing.
int32 GetError () const
 GetError.
uint16 GetPort () const
 GetPort.

Protected Member Functions

bool ProcessSystemMessage (CSystemMessage *pMsg)
 ProcessSystemMessage.
void ProcessModules ()
 ProcessModules.
void ProcessFileTx ()
 ProcessFileTx.


Detailed Description

CResource.

Description:

Limitations:


Constructor & Destructor Documentation

CResource::CResource  ) 
 

CResource.

Description: This constructor initializes internal class attributes.

Returns:
None
Limitations: None

CResource::~CResource  ) 
 

~CResource

Description: This destructor frees all allocated resources.

Returns:
None
Limitations: None


Member Function Documentation

bool CResource::AddParticipant CParticipant pParticipant  ) 
 

AddParticipant.

Description: This function adds a participant to the resource. This function is normally called indirectly by the CParticipant::AssignResource function.

Parameters:
pParticipant,: The participant to assign to the resource.
Returns:
bool: true if the participant was added.
Limitations: None

void CResource::Create CNetworkPlayer pConnection  ) 
 

Create.

Description: This function creates a resource's connect to a client machine.

Parameters:
pConnection,: The CNetworkPlayer object that is managing the connection to the resource machine.
Returns:
void
Limitations: None

int8 * CResource::GetAddress int8 *  buffer  )  const
 

GetAddress.

Description: This function returns the IP address of the resource.

Parameters:
buffer,: The buffer to be filled with the IP address.
Returns:
int8*: A pointer to the buffer. This always equals the buffer pointer.
Limitations: The buffer must be large enough to contain the output IP string.

uint32 CResource::GetAvgPing  )  const
 

GetAvgPing.

Description: This function returns the average calculated ping between the tournament server and the resource machine.

Returns:
uint32: The ping in milliseconds.
Limitations: None

uint64 CResource::GetBenchmark  )  const
 

GetBenchmark.

Description: This function returns the benchmark value collected from the resource machine. Check the bechmarking state to determine if this value is valid. The benchmark is only valid when the following condition is true.

m_ResourceState.bnchState == BENCH_READY

Returns:
void
Limitations: None

const CDescription * CResource::GetDescription  )  const
 

GetDescription.

Description: This function returns the description associated with the resource.

Returns:
CDescription*: A pointer to the description.
Limitations: None

int32 CResource::GetError  )  const
 

GetError.

Description: This function returns the last error code incurred by the CNetworkPlayer governing the resource connection.

Returns:
int32: The error code.
Limitations: None

CMessage * CResource::GetMessage  )  const
 

GetMessage.

Description: This function retrieves the oldest message received from the resource. Only messages that were not processed by the resource object are returned.

Returns:
CMessage*: A pointer to the newly-allocated CMessage storing the recieved message. This may be deleted when no longer needed.
Limitations: None

uint32 CResource::GetParticipantCount  )  const
 

GetParticipantCount.

Description: This function returns the total number of attached participants.

Returns:
uint32: The sum of all the attached participants
Limitations: None

void CResource::GetParticipantCount uint32 &  Humans,
uint32 &  AIs
const
 

GetParticipantCount.

Description: This function retrieves the number of each type of participant.

Parameters:
Humans,: Filled with the number of human players.
AIs,: Filled with the number of AI players.
Returns:
void
Limitations: None

void CResource::GetParticipants vector< CParticipant * > &  parts  )  const
 

GetParticipants.

Description: This function retrieves that list of attached participants.

Parameters:
parts,: The vector that will be filled with the participant list.
Returns:
void
Limitations: None

uint16 CResource::GetPort  )  const
 

GetPort.

Description: This function returns the port number that the resource will use. If the resource machine is a host, it will host of the returned port. If client, the resource will attempt to connect to the host machine on the port.

Returns:
uint16: The port number
Limitations: None

bool CResource::IsMsgAvail  )  const
 

IsMsgAvail.

Description: This function checks to see if any messages are available to read. Only messages that are not handled by the CResource's internal message handlers are made available.

Returns:
bool: True if messages are available.
Limitations: None

bool CResource::operator< const CResource  other  )  const
 

operator <

Description: This comparision operator is used to sort Resource objects. The objects are sorted based on the resources benchmark value.

Parameters:
other,: The other resource object with with this local object is compared.
Returns:
bool: True if the object's benchmark is less than the other's
Limitations: None

void CResource::Process  ) 
 

Process.

Description: This function performs 'thread' processing and should be called at a period rate.

Returns:
void
Limitations: None

void CResource::ProcessFileTx  )  [protected]
 

ProcessFileTx.

Description: This function governs the file transfer state machine. File transfer proceeds in the following steps: 1) The file trasfer is iniated when the state is set to TX_START_TRANSFER. This is done in the module loading state machine. 2) Once initated, the file is broken up into segments are each segment is sent to the client. 3) The final states are TX_COMPLETE, TX_FAILURE.

This state machine is imcomplete but has been included for future implementation. The current implementation automatically generates automatically transitions to the TX_FAILURE state.

Returns:
void
Limitations: None

void CResource::ProcessModules  )  [protected]
 

ProcessModules.

Description: This function runs the module loading state machine. It reads in module load request from the m_LoadQueue queue. Processing follows the following steps: 1) The existence of the module on the client machine is checked. 2) If the module is not on the client machine, the file transfer state machine is activated. 3) Once the file is on the client machine, the module is loaded. 4) The final states are MOD_FAILURE or MOD_COMPLETE.

It is important to note that the state machine is affected by the message processing function, OnSystemMessage, where the response messages are processed.

Returns:
void
Limitations: None

to the client.

bool CResource::ProcessSystemMessage CSystemMessage pMsg  )  [protected]
 

ProcessSystemMessage.

Description:

Parameters:
kevin is a character string.
Returns:
void
Limitations:

void CResource::ResetResource bool  bKillImmobile  ) 
 

ResetResource.

Description: This function commands the resource to reset. All mobile participants are unloaded.

Parameters:
bKillImmobile,: Flag that determines whether immoble participants are also unloaded.
Returns:
void
Limitations: None

void CResource::SendMessage CMessage pMsg  )  const
 

SendMessage.

Description: This funtion sends a message to the resource.

Parameters:
pMsg,: The message to be sent.
Returns:
void
Limitations: None.

void CResource::SetClient const CResource pHostResource  ) 
 

SetClient.

Description: This function configures the resource as a cleint. Client machines have subordiant clients and dispatchers. The machine will be commanded to connect to the specifed host resource.

Parameters:
pHostResource,: The host machine to which the client will connect.
Returns:
void
Limitations: A connection to the client machine must be established through the Create function.

void CResource::SetHost uint32  port  ) 
 

SetHost.

Description: This function configures the resource as a host. Host machines have dominant clients and dispatchers. The machine will be set to host on the specified port.

Parameters:
port,: The port on which the resource will host.
Returns:
void
Limitations: A connection to the client machine must be established through the Create function.

void CResource::UpdateBenchmark  ) 
 

UpdateBenchmark.

Description: This function request the benchmark value of the resource The benchmark can be retrieved later once the following state condition is met:

m_ResourceState.bnchState == BENCH_READY

Returns:
void
Limitations: None


The documentation for this class was generated from the following files:
Copyright (c) 2005 Matt Bruns, Pat Hammond, Kevin Markussen, Travis Service, Brain Shaver

SourceForge.net Logo