1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2020] [HCL Technologies Ltd.] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /* This file contains AlarmManager singleton class which is responsible for
20 storing and managing alarms.
24 #include "AlarmManager.hpp"
28 /* Default constructor */
29 AlarmManager::AlarmManager()
35 AlarmManager::~AlarmManager()
42 /**********************************************************************
43 Description : Raise an Alarm and store it in alarm list
45 Return : true - insert in map successful
46 false - insert in map unsuccessful
47 **********************************************************************/
48 bool AlarmManager::raiseAlarm(const Alarm& alarm)
51 pair<map<uint16_t,Alarm>::iterator,bool> ret;
52 ret = mAlarmList.insert(pair<uint16_t,Alarm>(alarm.getAlarmId(),alarm));
60 /**********************************************************************
61 Description : Clear an Alarm and delete it from alarm list
62 Params[In] : Alarm instance
63 Return : true - delete successful
64 false - delete unsuccessful
65 **********************************************************************/
66 bool AlarmManager::clearAlarm(const Alarm& alarm)
68 map<uint16_t,Alarm>::iterator it;
70 it = mAlarmList.find(alarm.getAlarmId());
71 if( it != mAlarmList.end() )
80 /**********************************************************************
81 Description : Clear an Alarm and delete it from alarm list with
84 Return : true - delete successful
85 false - delete unsuccessful
86 **********************************************************************/
87 bool AlarmManager::clearAlarm(const uint16_t& alarmId)
89 return (mAlarmList.erase(alarmId) > 0);
93 /**********************************************************************
94 Description : Return the list of active alarms
96 Return : constant reference to the map<int, Alarm>
97 **********************************************************************/
98 const map<uint16_t, Alarm>& AlarmManager::getAlarmList()const
104 /**********************************************************************
106 **********************************************************************/