Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006
00007 #if BOOST_VERSION >= 103900
00008 #include <boost/make_shared.hpp>
00009 #else // BOOST_VERSION >= 103900
00010 #include <boost/shared_ptr.hpp>
00011 #endif // BOOST_VERSION >= 103900
00012
00013 #include <stdair/basic/BasConst_General.hpp>
00014 #include <stdair/basic/BasConst_Event.hpp>
00015 #include <stdair/bom/BookingRequestStruct.hpp>
00016 #include <stdair/bom/OptimisationNotificationStruct.hpp>
00017 #include <stdair/bom/SnapshotStruct.hpp>
00018 #include <stdair/bom/CancellationStruct.hpp>
00019 #include <stdair/bom/RMEventStruct.hpp>
00020 #include <stdair/bom/EventStruct.hpp>
00021
00022 namespace stdair {
00023
00024
00025 EventStruct::EventStruct()
00026 : _eventType (EventType::BKG_REQ), _eventTimeStamp (0) {
00027 }
00028
00029
00030 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00031 BookingRequestPtr_T ioRequestPtr)
00032 : _eventType (iEventType) {
00033
00034
00035 assert (ioRequestPtr != NULL);
00036 #if BOOST_VERSION >= 103900
00037 _bookingRequest = boost::make_shared<BookingRequestStruct> (*ioRequestPtr);
00038 #else // BOOST_VERSION >= 103900
00039 _bookingRequest = ioRequestPtr;
00040 #endif // BOOST_VERSION >= 103900
00041 assert (_bookingRequest != NULL);
00042
00048 const Duration_T lDuration =
00049 _bookingRequest->getRequestDateTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00050 _eventTimeStamp = lDuration.total_milliseconds();
00051 }
00052
00053
00054 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00055 CancellationPtr_T ioCancellationPtr)
00056 : _eventType (iEventType) {
00057
00058
00059 assert (ioCancellationPtr != NULL);
00060 #if BOOST_VERSION >= 103900
00061 _cancellation = boost::make_shared<CancellationStruct> (*ioCancellationPtr);
00062 #else // BOOST_VERSION >= 103900
00063 _cancellation = ioCancellationPtr;
00064 #endif // BOOST_VERSION >= 103900
00065 assert (_cancellation != NULL);
00066
00072 const Duration_T lDuration =
00073 _cancellation->getCancellationDateTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00074 _eventTimeStamp = lDuration.total_milliseconds();
00075 }
00076
00077
00078 EventStruct::
00079 EventStruct (const EventType::EN_EventType& iEventType,
00080 const DateTime_T& iDCPDate,
00081 OptimisationNotificationPtr_T ioOptimisationNotificationPtr)
00082 : _eventType (iEventType) {
00083
00084
00085 assert (ioOptimisationNotificationPtr != NULL);
00086 #if BOOST_VERSION >= 103900
00087 _optimisationNotification =
00088 boost::make_shared<OptimisationNotificationStruct> (*ioOptimisationNotificationPtr);
00089 #else // BOOST_VERSION >= 103900
00090 _optimisationNotification = ioOptimisationNotificationPtr;
00091 #endif // BOOST_VERSION >= 103900
00092 assert (_optimisationNotification != NULL);
00093
00099 const Duration_T lDuration = iDCPDate - DEFAULT_EVENT_OLDEST_DATETIME;
00100 _eventTimeStamp = lDuration.total_milliseconds();
00101 }
00102
00103
00104 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00105 SnapshotPtr_T ioSnapshotPtr)
00106 : _eventType (iEventType) {
00107
00108
00109 assert (ioSnapshotPtr != NULL);
00110
00111 #if BOOST_VERSION >= 103900
00112 _snapshot = boost::make_shared<SnapshotStruct> (*ioSnapshotPtr);
00113 #else // BOOST_VERSION >= 103900
00114 _snapshot = ioSnapshotPtr;
00115 #endif // BOOST_VERSION >= 103900
00116 assert (_snapshot != NULL);
00117
00123 const Duration_T lDuration =
00124 _snapshot->getSnapshotTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00125 _eventTimeStamp = lDuration.total_milliseconds();
00126 }
00127
00128
00129 EventStruct::EventStruct (const EventType::EN_EventType& iEventType,
00130 RMEventPtr_T ioRMEventPtr)
00131 : _eventType (iEventType) {
00132
00133
00134 assert (ioRMEventPtr != NULL);
00135
00136 #if BOOST_VERSION >= 103900
00137 _rmEvent = boost::make_shared<RMEventStruct> (*ioRMEventPtr);
00138 #else // BOOST_VERSION >= 103900
00139 _rmEvent = ioRMEventPtr;
00140 #endif // BOOST_VERSION >= 103900
00141 assert (_rmEvent != NULL);
00142
00148 const Duration_T lDuration =
00149 _rmEvent->getRMEventTime() - DEFAULT_EVENT_OLDEST_DATETIME;
00150 _eventTimeStamp = lDuration.total_milliseconds();
00151 }
00152
00153
00154 EventStruct::EventStruct (const EventStruct& iEventStruct)
00155 : _eventType (iEventStruct._eventType),
00156 _eventTimeStamp (iEventStruct._eventTimeStamp) {
00157
00158
00159 if (iEventStruct._bookingRequest != NULL) {
00160 #if BOOST_VERSION >= 103900
00161 _bookingRequest =
00162 boost::make_shared<BookingRequestStruct>(*iEventStruct._bookingRequest);
00163 #else // BOOST_VERSION >= 103900
00164 _bookingRequest = iEventStruct._bookingRequest;
00165 #endif // BOOST_VERSION >= 103900
00166 }
00167
00168
00169 if (iEventStruct._cancellation != NULL) {
00170 #if BOOST_VERSION >= 103900
00171 _cancellation =
00172 boost::make_shared<CancellationStruct>(*iEventStruct._cancellation);
00173 #else // BOOST_VERSION >= 103900
00174 _cancellation = iEventStruct._cancellation;
00175 #endif // BOOST_VERSION >= 103900
00176 }
00177
00178
00179 if (iEventStruct._optimisationNotification != NULL) {
00180 #if BOOST_VERSION >= 103900
00181 _optimisationNotification =
00182 boost::make_shared<OptimisationNotificationStruct> (*iEventStruct._optimisationNotification);
00183 #else // BOOST_VERSION >= 103900
00184 _optimisationNotification = iEventStruct._optimisationNotification;
00185 #endif // BOOST_VERSION >= 103900
00186 }
00187
00188
00189 if (iEventStruct._snapshot != NULL) {
00190 #if BOOST_VERSION >= 103900
00191 _snapshot = boost::make_shared<SnapshotStruct> (*iEventStruct._snapshot);
00192 #else // BOOST_VERSION >= 103900
00193 _snapshot = iEventStruct._snapshot;
00194 #endif // BOOST_VERSION >= 103900
00195 }
00196
00197
00198 if (iEventStruct._rmEvent != NULL) {
00199 #if BOOST_VERSION >= 103900
00200 _rmEvent = boost::make_shared<RMEventStruct> (*iEventStruct._rmEvent);
00201 #else // BOOST_VERSION >= 103900
00202 _rmEvent = iEventStruct._rmEvent;
00203 #endif // BOOST_VERSION >= 103900
00204 }
00205 }
00206
00207
00208 EventStruct::~EventStruct() {
00209 }
00210
00211
00212 void EventStruct::fromStream (std::istream& ioIn) {
00213 }
00214
00215
00216 const std::string EventStruct::describe() const {
00217 std::ostringstream oStr;
00218
00219
00220 const Duration_T lEventDateTimeDelta =
00221 boost::posix_time::milliseconds (_eventTimeStamp);
00222 const DateTime_T lEventDateTime (DEFAULT_EVENT_OLDEST_DATETIME
00223 + lEventDateTimeDelta);
00224 oStr << lEventDateTime;
00225
00226
00227 switch (_eventType) {
00228 case EventType::BKG_REQ: {
00229 assert (_bookingRequest != NULL);
00230 oStr << ", " << _eventType << ", " << _bookingRequest->describe();
00231 break;
00232 }
00233 case EventType::CX: {
00234 assert (_cancellation != NULL);
00235 oStr << ", " << _eventType << ", " << _cancellation->describe();
00236 break;
00237 }
00238 case EventType::OPT_NOT_4_FD: {
00239 assert (_optimisationNotification != NULL);
00240 oStr << ", " << _eventType
00241 << ", " << _optimisationNotification->describe();
00242 break;
00243 }
00244 case EventType::SNAPSHOT: {
00245 assert (_snapshot != NULL);
00246 oStr << ", " << _eventType
00247 << ", " << _snapshot->describe();
00248 break;
00249 }
00250 case EventType::RM: {
00251 assert (_rmEvent != NULL);
00252 oStr << ", " << _eventType
00253 << ", " << _rmEvent->describe();
00254 break;
00255 }
00256 default: {
00257 oStr << ", " << _eventType << " (not yet recognised)";
00258 break;
00259 }
00260 }
00261
00262 return oStr.str();
00263 }
00264
00265 }