00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "order.h"
00013
00014 #include <boost/lexical_cast.hpp>
00015
00016 Order::Order(const SharedMemoryUIntAllocator &alloc,
00017 MarchingOrders::type march_orders)
00018 : communication_path(alloc),
00019 marching_orders(march_orders) {
00020 }
00021
00022 Order::Order(const Order& o)
00023 : communication_path(o.communication_path),
00024 marching_orders(o.marching_orders) {
00025 }
00026
00027 Order::~Order() {
00028 }
00029
00030 boost::interprocess::string
00031 Order::MarchingOrderTypeToString(MarchingOrders::type marching_order) {
00032 boost::interprocess::string order_as_string;
00033
00034 switch (marching_order) {
00035 case MarchingOrders::kAttack:
00036 order_as_string = boost::interprocess::string("Attack");
00037 break;
00038
00039 case MarchingOrders::kRetreat:
00040 order_as_string = boost::interprocess::string("Retreat");
00041 break;
00042
00043 case MarchingOrders::kInvalid:
00044 order_as_string = boost::interprocess::string("Invalid");
00045 break;
00046
00047 default:
00048 assert(false);
00049 break;
00050 }
00051
00052 return order_as_string;
00053 }
00054
00055 void Order::AppendCommPathEntry(const unsigned int kUniqueID) {
00056 communication_path.push_back(kUniqueID);
00057 }
00058
00059 boost::interprocess::string Order::CommunicationPathToString() const {
00060 boost::interprocess::string comm_path;
00061
00062 SharedMemoryUIntList::const_iterator communication_path_it;
00063 SharedMemoryUIntList::const_iterator communication_path_end;
00064
00065 for (communication_path_it = communication_path.begin(),
00066 communication_path_end = communication_path.end();
00067 communication_path_it != communication_path_end;
00068 ++communication_path_it) {
00069 comm_path.append(boost::lexical_cast<boost::interprocess::string>(
00070 *communication_path_it));
00071 comm_path.append(" ");
00072 }
00073
00074 return comm_path;
00075 }
00076