Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006
00007 #include <boost/make_shared.hpp>
00008
00009 #include <stdair/basic/BasConst_General.hpp>
00010 #include <stdair/basic/BasConst_Event.hpp>
00011 #include <stdair/bom/BookingRequestStruct.hpp>
00012 #include <stdair/bom/OptimisationNotificationStruct.hpp>
00013 #include <stdair/bom/SnapshotStruct.hpp>
00014 #include <stdair/bom/CancellationStruct.hpp>
00015 #include <stdair/bom/RMEventStruct.hpp>
00016 #include <stdair/bom/EventStruct.hpp>
00017
00018 namespace stdair {
00019
00020
00021 EventStruct::EventStruct()
00022 : _eventType (EventType::BKG_REQ), _eventTimeStamp (0) {
00023 }
00024
00025
00026 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00027 BookingRequestPtr_T ioRequestPtr)
00028 : _eventType (iEventType) {
00029
00030
00031 assert (ioRequestPtr != NULL);
00032 _bookingRequest = boost::make_shared<BookingRequestStruct> (*ioRequestPtr);
00033 assert (_bookingRequest != NULL);
00034
00040 const Duration_T lDuration =
00041 _bookingRequest->getRequestDateTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00042 _eventTimeStamp = lDuration.total_milliseconds();
00043 }
00044
00045
00046 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00047 CancellationPtr_T ioCancellationPtr)
00048 : _eventType (iEventType) {
00049
00050
00051 assert (ioCancellationPtr != NULL);
00052 _cancellation = boost::make_shared<CancellationStruct> (*ioCancellationPtr);
00053 assert (_cancellation != NULL);
00054
00060 const Duration_T lDuration =
00061 _cancellation->getCancellationDateTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00062 _eventTimeStamp = lDuration.total_milliseconds();
00063 }
00064
00065
00066 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00067 const DateTime_T& iDCPDate,
00068 OptimisationNotificationPtr_T ioOptimisationNotificationPtr)
00069 : _eventType (iEventType) {
00070
00071
00072 assert (ioOptimisationNotificationPtr != NULL);
00073 _optimisationNotification =
00074 boost::make_shared<OptimisationNotificationStruct> (*ioOptimisationNotificationPtr);
00075 assert (_optimisationNotification != NULL);
00076
00082 const Duration_T lDuration = iDCPDate - DEFAULT_EVENT_OLDEST_DATETIME;
00083 _eventTimeStamp = lDuration.total_milliseconds();
00084 }
00085
00086
00087 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00088 SnapshotPtr_T ioSnapshotPtr)
00089 : _eventType (iEventType) {
00090
00091
00092 assert (ioSnapshotPtr != NULL);
00093 _snapshot = boost::make_shared<SnapshotStruct> (*ioSnapshotPtr);
00094 assert (_snapshot != NULL);
00095
00101 const Duration_T lDuration =
00102 _snapshot->getSnapshotTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00103 _eventTimeStamp = lDuration.total_milliseconds();
00104 }
00105
00106
00107 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00108 RMEventPtr_T ioRMEventPtr)
00109 : _eventType (iEventType) {
00110
00111
00112 assert (ioRMEventPtr != NULL);
00113 _rmEvent = boost::make_shared<RMEventStruct> (*ioRMEventPtr);
00114 assert (_rmEvent != NULL);
00115
00121 const Duration_T lDuration =
00122 _rmEvent->getRMEventTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00123 _eventTimeStamp = lDuration.total_milliseconds();
00124 }
00125
00126
00127 EventStruct::EventStruct (const EventStruct& iEventStruct)
00128 : _eventType (iEventStruct._eventType),
00129 _eventTimeStamp (iEventStruct._eventTimeStamp) {
00130
00131
00132 if (iEventStruct._bookingRequest != NULL) {
00133 _bookingRequest =
00134 boost::make_shared<BookingRequestStruct>(*iEventStruct._bookingRequest);
00135 }
00136
00137
00138 if (iEventStruct._cancellation != NULL) {
00139 _cancellation =
00140 boost::make_shared<CancellationStruct>(*iEventStruct._cancellation);
00141 }
00142
00143
00144 if (iEventStruct._optimisationNotification != NULL) {
00145 _optimisationNotification =
00146 boost::make_shared<OptimisationNotificationStruct> (*iEventStruct._optimisationNotification);
00147 }
00148
00149
00150 if (iEventStruct._snapshot != NULL) {
00151 _snapshot =
00152 boost::make_shared<SnapshotStruct>(*iEventStruct._snapshot);
00153 }
00154
00155
00156 if (iEventStruct._rmEvent != NULL) {
00157 _rmEvent =
00158 boost::make_shared<RMEventStruct>(*iEventStruct._rmEvent);
00159 }
00160 }
00161
00162
00163 EventStruct::~EventStruct() {
00164 }
00165
00166
00167 void EventStruct::fromStream (std::istream& ioIn) {
00168 }
00169
00170
00171 const std::string EventStruct::describe() const {
00172 std::ostringstream oStr;
00173
00174
00175 const Duration_T lEventDateTimeDelta =
00176 boost::posix_time::milliseconds (_eventTimeStamp);
00177 const DateTime_T lEventDateTime (DEFAULT_EVENT_OLDEST_DATETIME
00178 + lEventDateTimeDelta);
00179 oStr << lEventDateTime;
00180
00181
00182 switch (_eventType) {
00183 case EventType::BKG_REQ: {
00184 assert (_bookingRequest != NULL);
00185 oStr << ", " << _eventType << ", " << _bookingRequest->describe();
00186 break;
00187 }
00188 case EventType::CX: {
00189 assert (_cancellation != NULL);
00190 oStr << ", " << _eventType << ", " << _cancellation->describe();
00191 break;
00192 }
00193 case EventType::OPT_NOT_4_FD: {
00194 assert (_optimisationNotification != NULL);
00195 oStr << ", " << _eventType
00196 << ", " << _optimisationNotification->describe();
00197 break;
00198 }
00199 case EventType::SNAPSHOT: {
00200 assert (_snapshot != NULL);
00201 oStr << ", " << _eventType
00202 << ", " << _snapshot->describe();
00203 break;
00204 }
00205 case EventType::RM: {
00206 assert (_rmEvent != NULL);
00207 oStr << ", " << _eventType
00208 << ", " << _rmEvent->describe();
00209 break;
00210 }
00211 default: {
00212 oStr << ", " << _eventType << " (not yet recognised)";
00213 break;
00214 }
00215 }
00216
00217 return oStr.str();
00218 }
00219
00220 }