CLIHandler Class Reference

This class is responsible for providing an execution harness into the Byzantine Generals coding sample. It is intended to be called directly from main(). More...

#include <clihandler.h>

Collaboration diagram for CLIHandler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CLIHandler ()
 Constructor.
 ~CLIHandler ()
 Destructor.
ByzGeneralsReturnCodes::type Exec (int argc, char *argv[])
 Begin execution of the Byzantine General coding sample. This function will not return until all of the threads which are created are completed.

Private Member Functions

log4cpp::Category & InitializeLogger ()
 Create a logging endpoint.
ByzGeneralsReturnCodes::type ParseAndValidateArguments (int argc, char *argv[])
 Parse and validate command line arguments (CLI).
void CreateGeneralThreads ()
 Create the Byzantine General Threads. This function will store created thread references into byzantine_generals_.
void DestroyGeneralThreads ()
 Destroy Byzantine General Threads. This function will destroy any thread references stored in byzantine_generals_ Threads should be completed prior to calling this function.
void CalculateOrdersAndRounds ()
 Calculate the number of orders each general should expect and the total number of rounds that those orders will be sent across.
void CreateSharedMemoryItems ()
 Create shared memory region and the data structures within the shared memory region (Traitor Set, Mailbox Vector, etc..).
void DestroySharedMemoryItems ()
 Destroy the shared memory region and all of its contents.

Private Attributes

log4cpp::Category & log_
 Logging endpoint.
unsigned int number_rounds_
 The number of rounds that communication will take place over. This is always m + 1, where m is the number of traitors the user specified.
unsigned int number_traitor_generals_
 User specified number of traitor (disloyal) generals.
unsigned int number_loyal_generals_
 User specified number of loyal generals.
bool generate_dot_graph_
 User specified generation of DOT graphs, TRUE to generate graphs, FALSE otherwise.
unsigned int total_number_generals_
 Calculated total number of general (always equal to the number of loyal generals + number of disloyal generals).
unsigned int total_messages_per_lt_general_
 Calculated total number of messages that each Lieutenant General should expect to receive.
std::vector
< ByzantineGeneralThread * > 
byzantine_generals_
 This vector stores references to the created Byzantine General Threads. It is populated by CreateGeneralThreads and cleared by DestroyGeneralThreads.
boost::interprocess::managed_shared_memory * segment_
 Reference to the created shared memory region. It is populated by CreateSharedMemoryItems and destroyed by DestroySharedMemoryItems.
SharedMemoryUIntSettraitor_set_
 This set, which is stored in shared memory, keeps track of the unique identifiers of each of the disloyal Byzantine General Threads. It is populated by CreateSharedMemoryItems and destroyed by DestroySharedMemoryItems.
SharedMemoryMailboxVectormailbox_vector_
 This vector stores the mailboxes for each of the Generals. See Mailbox for details. It is populated by CreateSharedMemoryItems and destroyed by DestroySharedMemoryItems.

Static Private Attributes

static const char * kSharedMemoryName_ = "ByzGeneralsSharedMemory"
 Shared memory region name. This is the unique identifier used to find the region of memory shared between the various Byzantine General Threads. All shared objects are stored in this region.
static const char * kMailboxVectorName_ = "ByzGeneralsMailboxVector"
 Mailbox vector (in shared memory) name. See Mailbox for details on what each Mailbox is used for.
static const char * kTraitorSetName_ = "ByzGeneralsTraitorSet"
 Traitor set (in shared memory) name. This is a simple set used to track the Generals who are created as traitors.
static const char * kLogCategoryName_ = "ByzGeneralsLogCategory"
 Logging category name.
static const int kSharedMemoryMaxSize_ = 50000000
 Maximum size of shared memory region in bytes. We pick a maximum memory area size sufficiently large to allow testing of up to 4 traitors and 9 loyalists. This value can be increased arbitrairly to test larger cases.

Detailed Description

This class is responsible for providing an execution harness into the Byzantine Generals coding sample. It is intended to be called directly from main().

Definition at line 45 of file clihandler.h.


Constructor & Destructor Documentation

CLIHandler::CLIHandler (  ) 

Constructor.

Definition at line 34 of file clihandler.cpp.

CLIHandler::~CLIHandler (  ) 

Destructor.

Definition at line 48 of file clihandler.cpp.


Member Function Documentation

void CLIHandler::CalculateOrdersAndRounds (  )  [private]

Calculate the number of orders each general should expect and the total number of rounds that those orders will be sent across.

Definition at line 227 of file clihandler.cpp.

Here is the caller graph for this function:

void CLIHandler::CreateGeneralThreads (  )  [private]

Create the Byzantine General Threads. This function will store created thread references into byzantine_generals_.

Definition at line 337 of file clihandler.cpp.

Here is the caller graph for this function:

void CLIHandler::CreateSharedMemoryItems (  )  [private]

Create shared memory region and the data structures within the shared memory region (Traitor Set, Mailbox Vector, etc..).

Definition at line 268 of file clihandler.cpp.

Here is the caller graph for this function:

void CLIHandler::DestroyGeneralThreads (  )  [private]

Destroy Byzantine General Threads. This function will destroy any thread references stored in byzantine_generals_ Threads should be completed prior to calling this function.

Definition at line 404 of file clihandler.cpp.

Here is the caller graph for this function:

void CLIHandler::DestroySharedMemoryItems (  )  [private]

Destroy the shared memory region and all of its contents.

Definition at line 313 of file clihandler.cpp.

Here is the caller graph for this function:

ByzGeneralsReturnCodes::type CLIHandler::Exec ( int  argc,
char *  argv[] 
)

Begin execution of the Byzantine General coding sample. This function will not return until all of the threads which are created are completed.

Parameters:
argc Command Line argument count
argv Command Line argument values
Returns:
The result of parsing arguments and creating/executing of the threads

Definition at line 51 of file clihandler.cpp.

Here is the call graph for this function:

log4cpp::Category & CLIHandler::InitializeLogger (  )  [private]

Create a logging endpoint.

Returns:
Logging endpoint reference

Definition at line 112 of file clihandler.cpp.

ByzGeneralsReturnCodes::type CLIHandler::ParseAndValidateArguments ( int  argc,
char *  argv[] 
) [private]

Parse and validate command line arguments (CLI).

Parameters:
argc Command Line argument count
argv Command Line argument values
Returns:
Status of argument parsing

Definition at line 136 of file clihandler.cpp.

Here is the caller graph for this function:


Member Data Documentation

This vector stores references to the created Byzantine General Threads. It is populated by CreateGeneralThreads and cleared by DestroyGeneralThreads.

Definition at line 198 of file clihandler.h.

User specified generation of DOT graphs, TRUE to generate graphs, FALSE otherwise.

Definition at line 179 of file clihandler.h.

const char * CLIHandler::kLogCategoryName_ = "ByzGeneralsLogCategory" [static, private]

Logging category name.

Definition at line 95 of file clihandler.h.

const char * CLIHandler::kMailboxVectorName_ = "ByzGeneralsMailboxVector" [static, private]

Mailbox vector (in shared memory) name. See Mailbox for details on what each Mailbox is used for.

Definition at line 84 of file clihandler.h.

const int CLIHandler::kSharedMemoryMaxSize_ = 50000000 [static, private]

Maximum size of shared memory region in bytes. We pick a maximum memory area size sufficiently large to allow testing of up to 4 traitors and 9 loyalists. This value can be increased arbitrairly to test larger cases.

Definition at line 103 of file clihandler.h.

const char * CLIHandler::kSharedMemoryName_ = "ByzGeneralsSharedMemory" [static, private]

Shared memory region name. This is the unique identifier used to find the region of memory shared between the various Byzantine General Threads. All shared objects are stored in this region.

Definition at line 78 of file clihandler.h.

const char * CLIHandler::kTraitorSetName_ = "ByzGeneralsTraitorSet" [static, private]

Traitor set (in shared memory) name. This is a simple set used to track the Generals who are created as traitors.

Definition at line 90 of file clihandler.h.

log4cpp::Category& CLIHandler::log_ [private]

Logging endpoint.

Definition at line 108 of file clihandler.h.

This vector stores the mailboxes for each of the Generals. See Mailbox for details. It is populated by CreateSharedMemoryItems and destroyed by DestroySharedMemoryItems.

Definition at line 221 of file clihandler.h.

unsigned int CLIHandler::number_loyal_generals_ [private]

User specified number of loyal generals.

Definition at line 173 of file clihandler.h.

unsigned int CLIHandler::number_rounds_ [private]

The number of rounds that communication will take place over. This is always m + 1, where m is the number of traitors the user specified.

Definition at line 163 of file clihandler.h.

unsigned int CLIHandler::number_traitor_generals_ [private]

User specified number of traitor (disloyal) generals.

Definition at line 168 of file clihandler.h.

boost::interprocess::managed_shared_memory* CLIHandler::segment_ [private]

Reference to the created shared memory region. It is populated by CreateSharedMemoryItems and destroyed by DestroySharedMemoryItems.

Definition at line 205 of file clihandler.h.

Calculated total number of messages that each Lieutenant General should expect to receive.

Definition at line 191 of file clihandler.h.

unsigned int CLIHandler::total_number_generals_ [private]

Calculated total number of general (always equal to the number of loyal generals + number of disloyal generals).

Definition at line 185 of file clihandler.h.

This set, which is stored in shared memory, keeps track of the unique identifiers of each of the disloyal Byzantine General Threads. It is populated by CreateSharedMemoryItems and destroyed by DestroySharedMemoryItems.

Definition at line 213 of file clihandler.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
Generated on Mon May 31 15:35:43 2010 for Byzantine Generals Coding Sample by  doxygen 1.6.3