00001 00034 #include "alarmstatusentry.h" 00035 00036 using namespace AlarmNotifications; 00037 00038 AlarmStatusEntry::AlarmStatusEntry ( const std::string& pvname, const std::string& severity, const std::string& status ) noexcept 00039 : 00040 _pvname ( pvname ), 00041 _severity ( severity ), 00042 _status ( status ), 00043 _triggertime ( std::time ( nullptr ) ), 00044 _desktopNotificationSent ( false ), 00045 _emailNotificationSent ( false ) 00046 { 00047 00048 } 00049 00050 AlarmStatusEntry::~AlarmStatusEntry() noexcept 00051 { 00052 00053 } 00054 00055 AlarmStatusEntry::AlarmStatusEntry ( const AlarmStatusEntry& other ) noexcept 00056 : 00057 _pvname ( other._pvname ), 00058 _severity ( other._severity ), 00059 _status ( other._status ), 00060 _triggertime ( other._triggertime ), 00061 _desktopNotificationSent ( other._desktopNotificationSent ), 00062 _emailNotificationSent ( other._emailNotificationSent ) 00063 { 00064 00065 } 00066 00067 AlarmStatusEntry::AlarmStatusEntry ( AlarmStatusEntry&& other ) noexcept 00068 : 00069 _pvname ( std::move ( other._pvname ) ), 00070 _severity ( std::move ( other._severity ) ), 00071 _status ( std::move ( other._status ) ), 00072 _triggertime ( other._triggertime ), 00073 _desktopNotificationSent ( other._desktopNotificationSent ), 00074 _emailNotificationSent ( other._emailNotificationSent ) 00075 { 00076 00077 } 00078 00079 AlarmStatusEntry& AlarmStatusEntry::operator= ( const AlarmStatusEntry& other ) noexcept 00080 { 00081 if ( this != &other ) 00082 { 00083 _pvname = other._pvname; 00084 _severity = other._severity; 00085 _status = other._status; 00086 _triggertime = other._triggertime; 00087 _desktopNotificationSent = other._desktopNotificationSent; 00088 _emailNotificationSent = other._emailNotificationSent; 00089 } 00090 return *this; 00091 } 00092 00093 AlarmStatusEntry& AlarmStatusEntry::operator= ( AlarmStatusEntry&& other ) noexcept 00094 { 00095 if ( this != &other ) 00096 { 00097 _pvname = std::move ( other._pvname ); 00098 _severity = std::move ( other._severity ); 00099 _status = std::move ( other._status ); 00100 _triggertime = other._triggertime; 00101 _desktopNotificationSent = other._desktopNotificationSent; 00102 _emailNotificationSent = other._emailNotificationSent; 00103 } 00104 return *this; 00105 } 00106 00107 bool AlarmStatusEntry::operator== ( const AlarmStatusEntry& other ) noexcept 00108 { 00109 return ( _pvname == other._pvname ) && ( _severity == other._severity ) && ( _status == other._status ) && ( _triggertime == other._triggertime ) && ( _desktopNotificationSent == other._desktopNotificationSent ) && ( _emailNotificationSent == other._emailNotificationSent ); 00110 } 00111 00112 const std::string& AlarmStatusEntry::getPVName() const noexcept 00113 { 00114 return _pvname; 00115 } 00116 00117 const std::string& AlarmStatusEntry::getSeverity() const noexcept 00118 { 00119 return _severity; 00120 } 00121 00122 void AlarmStatusEntry::setSeverity ( const std::string& severity ) noexcept 00123 { 00124 _severity = severity; 00125 } 00126 00127 const std::string& AlarmStatusEntry::getStatus() const noexcept 00128 { 00129 return _status; 00130 } 00131 00132 void AlarmStatusEntry::setStatus ( const std::string& status ) noexcept 00133 { 00134 _status = status; 00135 } 00136 00137 time_t AlarmStatusEntry::getTriggerTime() const noexcept 00138 { 00139 return _triggertime; 00140 } 00141 00142 void AlarmStatusEntry::setTriggerTime ( const time_t triggertime ) noexcept 00143 { 00144 _triggertime = triggertime; 00145 } 00146 00147 void AlarmStatusEntry::update ( const AlarmStatusEntry& newdata ) noexcept 00148 { 00149 if ( _triggertime < newdata._triggertime ) 00150 { 00151 _severity = newdata._severity; 00152 _status = newdata._status; 00153 } 00154 } 00155 00156 bool AlarmStatusEntry::getDesktopNotificationSent() const noexcept 00157 { 00158 return _desktopNotificationSent; 00159 } 00160 00161 void AlarmStatusEntry::setDesktopNotificationSent ( const bool desktopNotificationSent ) noexcept 00162 { 00163 _desktopNotificationSent = desktopNotificationSent; 00164 } 00165 00166 bool AlarmStatusEntry::getEmailNotificationSent() const noexcept 00167 { 00168 return _emailNotificationSent; 00169 } 00170 00171 void AlarmStatusEntry::setEmailNotificationSent ( const bool emailNotificationSent ) noexcept 00172 { 00173 _emailNotificationSent = emailNotificationSent; 00174 } 00175 00176 std::ostream& AlarmNotifications::operator<< ( std::ostream& os, const AlarmNotifications::AlarmStatusEntry& ase ) 00177 { 00178 os << "PV: " << ase.getPVName() << " Severity: " << ase.getSeverity() << " Status: " << ase.getStatus() << " Time: " << ase.getTriggerTime(); 00179 return os; 00180 }