summaryrefslogtreecommitdiff
path: root/polux/application/agent/inc/AlarmListManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'polux/application/agent/inc/AlarmListManager.h')
-rwxr-xr-xpolux/application/agent/inc/AlarmListManager.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/polux/application/agent/inc/AlarmListManager.h b/polux/application/agent/inc/AlarmListManager.h
new file mode 100755
index 0000000000..31d3370b4a
--- /dev/null
+++ b/polux/application/agent/inc/AlarmListManager.h
@@ -0,0 +1,162 @@
+/*
+ ****************************************************************************
+ * PROGRAM MODULE
+ *
+ * $Workfile: systemmanager.h $
+ * $Author: antunes $
+ * $Date: 2006/02/10 08:21:50 $
+ *
+ * Copyright (C) 2003 by SPiDCOM Technologies All rights reserved.
+ *
+ ****************************************************************************
+ */
+
+#ifndef __ALARM_LIST_MANAGER__
+#define __ALARM_LIST_MANAGER__
+
+
+#include "AlarmList.h"
+#include <pthread.h>
+
+
+
+
+//using namespace threads_namespace;
+using namespace agentsnmp;
+
+
+/**
+* Alarm List Manager
+* This class is responsible of the list management, but not for the list memory allocation
+* - build the list and the counter Id from flash
+* - save the list and the counter Id in flash
+* - Mutex on file access for saving/creating the list of alarms (ThreadManager)
+*/
+
+
+
+class AlarmListManager //: public commonThreadManager
+
+{
+
+
+public:
+
+ virtual ~AlarmListManager();
+
+
+ /**
+ * Get a copy of alarms managed currently:
+ * During the update WRITING is excluded by LOCK, but READING still allowed
+ */
+ void getCopyOfAlarmList(agentsnmp::commonOrderedList<AlarmObjectModel>& oAlarmList);
+
+
+ /**
+ * Get a copy of alarms managed currently
+ */
+ //agentsnmp::commonOrderedList<AlarmObjectModel>* getCopyOfAlarmList();
+
+
+ /**
+ * Get the element from the index in the list
+ * return NULL if i> size of list
+ */
+ //AlarmObjectModel* getAlarmObjectModel(int indexInList);
+
+
+
+ /**
+ * Update the list and save it in file.
+ * Two different updates can happen:
+ * - create a new alarm if event generates a new alarm object
+ * - update an existing one if event refers to an already existing alarm
+ * In the two casses, a pointer on the list contained objet is returned
+ *
+ * During the update WRITING AND READING are excluded by LOCK
+ */
+ const AlarmObjectModel* updateAlarmList(AlarmObjectModel& iAlarmFromEvent);
+
+
+ /**
+ * Modify the status of alarm, in order to terminate it into the equipment
+ */
+ void terminateAlarm(unsigned long int& aAlarmId);
+
+ /**
+ * Remove all alarms which status is terminate
+ */
+ void removeAllTerminateAlarms();
+
+ /**
+ * Fill the AlarmListManager list of alarms thanks to reading the dedicated file saved in flash memory
+ * During the creation, WRITING AND READING are excluded by LOCK
+ */
+ bool createAlarmListFromFlash();
+
+
+
+
+ /**
+ * To avoid singleton memory leaks
+ */
+ void freeMemory();
+
+
+
+
+ /////////////////////////////////////////////////////////////////////
+ // Singleton static accessor
+ static AlarmListManager* instance();
+
+
+
+
+
+
+private:
+
+ // The attribute m_list is instanciate in the constructor
+ AlarmList m_alarmList;
+
+ // Singleton => constructor private
+ AlarmListManager();
+
+ //Singleton
+ static AlarmListManager* m_instance_p;
+
+ //Lock read-write access
+ pthread_rwlock_t m_readwrite_lock;
+
+
+ /**
+ * The alarmIdCounter is setted in the method createAlarmListFromFlash, defined above in this class
+ * No possibility to manage it directly from another class
+ */
+ void setAlarmIdCounter(long i);
+
+
+ /**
+ * Get/set/increase the counter
+ */
+ //long getAlarmIdCounter();
+
+
+ /**
+ * Get a pointer to the List of alarms
+ */
+ //const agentsnmp::commonOrderedList<AlarmObjectModel>* getAlarmList();
+
+
+ /**
+ * Save the list of alarms thanks to writting in the dedicated file saved in flash memory
+ * Before overwritting, save the old file (sufix Old added in the name)
+ */
+ bool saveAlarmListInFlash();
+
+
+};
+
+
+
+#endif //__ALARM_LIST_MANAGER__