Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006 #include <sstream>
00007
00008 #include <stdair/stdair_exceptions.hpp>
00009 #include <stdair/basic/EventType.hpp>
00010
00011 namespace stdair {
00012
00013
00014 const std::string EventType::_labels[LAST_VALUE] =
00015 { "BookingRequest", "Cancellation","OptimisationNotificationForFlightDate",
00016 "OptimisationNotificationForNetwork", "ScheduleChange", "Snapshot",
00017 "RevenueMangement", "BreakPoint" };
00018
00019
00020 const char EventType::
00021 _typeLabels[LAST_VALUE] = { 'B', 'X', 'F', 'N', 'C', 'S', 'R', 'P' };
00022
00023
00024
00025 EventType::EventType()
00026 : _type (LAST_VALUE) {
00027 assert (false);
00028 }
00029
00030
00031 EventType::EventType (const EventType& iEventType)
00032 : _type (iEventType._type) {
00033 }
00034
00035
00036 EventType::EventType (const EN_EventType& iEventType)
00037 : _type (iEventType) {
00038 }
00039
00040
00041 EventType::EventType (const char iType) {
00042 switch (iType) {
00043 case 'B': _type = BKG_REQ; break;
00044 case 'X': _type = CX; break;
00045 case 'F': _type = OPT_NOT_4_FD; break;
00046 case 'N': _type = OPT_NOT_4_NET; break;
00047 case 'C': _type = SKD_CHG; break;
00048 case 'S': _type = SNAPSHOT; break;
00049 case 'R': _type = RM; break;
00050 case 'P': _type = BRK_PT; break;
00051 default: _type = LAST_VALUE; break;
00052 }
00053
00054 if (_type == LAST_VALUE) {
00055 const std::string& lLabels = describeLabels();
00056 std::ostringstream oMessage;
00057 oMessage << "The event type '" << iType
00058 << "' is not known. Known event types: " << lLabels;
00059 throw CodeConversionException (oMessage.str());
00060 }
00061 }
00062
00063
00064 const std::string& EventType::getLabel (const EN_EventType& iType) {
00065 return _labels[iType];
00066 }
00067
00068
00069 char EventType::getTypeLabel (const EN_EventType& iType) {
00070 return _typeLabels[iType];
00071 }
00072
00073
00074 std::string EventType::getTypeLabelAsString (const EN_EventType& iType) {
00075 std::ostringstream oStr;
00076 oStr << _typeLabels[iType];
00077 return oStr.str();
00078 }
00079
00080
00081 std::string EventType::describeLabels() {
00082 std::ostringstream ostr;
00083 for (unsigned short idx = 0; idx != LAST_VALUE; ++idx) {
00084 if (idx != 0) {
00085 ostr << ", ";
00086 }
00087 ostr << _labels[idx];
00088 }
00089 return ostr.str();
00090 }
00091
00092
00093 EventType::EN_EventType EventType::getType() const {
00094 return _type;
00095 }
00096
00097
00098 std::string EventType::getTypeAsString() const {
00099 std::ostringstream oStr;
00100 oStr << _typeLabels[_type];
00101 return oStr.str();
00102 }
00103
00104
00105 const std::string EventType::describe() const {
00106 std::ostringstream ostr;
00107 ostr << _labels[_type];
00108 return ostr.str();
00109 }
00110
00111
00112 bool EventType::operator== (const EN_EventType& iType) const {
00113 return (_type == iType);
00114 }
00115
00116 }