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>

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. | |
| SharedMemoryUIntSet * | traitor_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. | |
| SharedMemoryMailboxVector * | mailbox_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. | |
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.
| CLIHandler::CLIHandler | ( | ) |
Constructor.
Definition at line 34 of file clihandler.cpp.
| CLIHandler::~CLIHandler | ( | ) |
Destructor.
Definition at line 48 of file clihandler.cpp.
| 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.

| 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.

| 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.

| 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.

| void CLIHandler::DestroySharedMemoryItems | ( | ) | [private] |
Destroy the shared memory region and all of its contents.
Definition at line 313 of file clihandler.cpp.

| 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.
| argc | Command Line argument count | |
| argv | Command Line argument values |
Definition at line 51 of file clihandler.cpp.

| log4cpp::Category & CLIHandler::InitializeLogger | ( | ) | [private] |
Create a logging endpoint.
Definition at line 112 of file clihandler.cpp.
| ByzGeneralsReturnCodes::type CLIHandler::ParseAndValidateArguments | ( | int | argc, | |
| char * | argv[] | |||
| ) | [private] |
Parse and validate command line arguments (CLI).
| argc | Command Line argument count | |
| argv | Command Line argument values |
Definition at line 136 of file clihandler.cpp.

std::vector<ByzantineGeneralThread *> CLIHandler::byzantine_generals_ [private] |
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.
bool CLIHandler::generate_dot_graph_ [private] |
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.
unsigned int CLIHandler::total_messages_per_lt_general_ [private] |
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.
SharedMemoryUIntSet* CLIHandler::traitor_set_ [private] |
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.
1.6.3