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)
50 pair<map<uint16_t,Alarm>::iterator,bool> ret;
51 ret = mAlarmList.insert(pair<uint16_t,Alarm>(alarm.getAlarmId(),alarm));
57 /**********************************************************************
58 Description : Clear an Alarm and delete it from alarm list
59 Params[In] : Alarm instance
60 Return : true - delete successful
61 false - delete unsuccessful
62 **********************************************************************/
63 bool AlarmManager::clearAlarm(const Alarm& alarm)
65 map<uint16_t,Alarm>::iterator it;
67 it = mAlarmList.find(alarm.getAlarmId());
68 if( it != mAlarmList.end() )
77 /**********************************************************************
78 Description : Clear an Alarm and delete it from alarm list with
81 Return : true - delete successful
82 false - delete unsuccessful
83 **********************************************************************/
84 bool AlarmManager::clearAlarm(const uint16_t& alarmId)
86 return (mAlarmList.erase(alarmId) > 0);
90 /**********************************************************************
91 Description : Return the list of active alarms
93 Return : constant reference to the map<int, Alarm>
94 **********************************************************************/
95 const map<uint16_t, Alarm>& AlarmManager::getAlarmList()const
101 /**********************************************************************
103 **********************************************************************/