summaryrefslogtreecommitdiff
path: root/polux/application/agent/src/AlarmList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polux/application/agent/src/AlarmList.cpp')
-rw-r--r--polux/application/agent/src/AlarmList.cpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/polux/application/agent/src/AlarmList.cpp b/polux/application/agent/src/AlarmList.cpp
new file mode 100644
index 0000000000..ca5ee88f5c
--- /dev/null
+++ b/polux/application/agent/src/AlarmList.cpp
@@ -0,0 +1,186 @@
+/*
+ ****************************************************************************
+ * PROGRAM MODULE
+ *
+ * $Workfile: agent.cpp $
+ * $Author: poullain $
+ * $Date: 2005/07/18 13:26:53 $
+ *
+ * Copyright (C) 2004 by SPiDCOM Technologies All rights reserved.
+ *
+ ****************************************************************************
+ */
+
+#ifndef _AlarmList_cpp
+#define _AlarmList_cpp
+
+#include <assert.h>
+
+#include "AlarmList.h"
+#include "macro.h"
+
+
+using namespace agentsnmp;
+
+
+// The constructor is responsible of allocation of memory for the ordered list
+AlarmList::AlarmList(): m_list(agentsnmp::commonOrderedList<AlarmObjectModel>())
+{
+ m_alarmIdCounter = 0;
+}
+
+
+// The destructor is responsible of de-allocation of memory for the ordered list
+AlarmList::~AlarmList()
+{
+ m_list.clearAll();
+ /* if (m_list!=NULL)
+ {
+ m_list->clearAll();
+ delete m_list;
+ }*/
+}
+
+
+agentsnmp::commonOrderedList<AlarmObjectModel>& AlarmList::getListOfAlarm()
+{
+ //m_list can be empty, but not VOID
+ //assert (0 != m_list);
+ return m_list;
+}
+
+
+
+
+void AlarmList::getCopyListOfAlarm(agentsnmp::commonOrderedList<AlarmObjectModel>& oAlarmList)
+{
+ //m_list can be empty, but not VOID
+ //assert (0 != m_list);
+ m_list.clone(oAlarmList);
+}
+
+
+
+
+
+/**
+ * try to find the alarm in the list
+ * return null if no alarm found
+ *
+ */
+AlarmObjectModel* AlarmList::find(const AlarmObjectModel& iAlarm)
+{
+ AlarmObjectModel* result = NULL;
+
+ if (!m_list.empty())
+ {
+ agentsnmp::commonListCursor<AlarmObjectModel> cur;
+ for (cur.init(&m_list); cur.get(); cur.next())
+ {
+ if (*cur.get() > iAlarm)
+ {
+ break;
+ }
+ else if (iAlarm == *cur.get())
+ {
+ result = cur.get();
+ }
+
+ }
+ }
+ return result;
+}
+
+
+
+/**
+ * Remove all alarms which status is terminate
+ */
+void AlarmList::removeAllTerminateAlarms()
+{
+
+ if (!m_list.empty())
+ {
+ DEBUG("Alarm list is not empty"<<endl);
+
+ agentsnmp::commonOrderedListCursor<AlarmObjectModel> cur;
+ agentsnmp::commonListItem<AlarmObjectModel>* tmp;
+
+
+ for (cur.init(&m_list);cur.get();cur.next())
+ {
+ tmp = cur.get_cursor();
+ assert( (tmp!=0) && (tmp->getItem()!=0) );
+ if (tmp->getItem()->getAlarmStatus() == ((AlarmObjectModel::alarmStatus) 3))
+ {
+ DEBUG("Item to delete: "<< tmp->getItem()->getAlarmId() <<endl);
+ tmp = m_list.remove_element(tmp);
+ }
+ }
+
+ /*
+ //cur.init(&m_list);
+ while( (tmp!=0) && (tmp->getItem()!=0) )
+ {
+ if (tmp->getItem()->getAlarmStatus() == ((AlarmObjectModel::alarmStatus) 3))
+ {
+ DEBUG("Item to delete: "<< tmp->getItem()->getAlarmId() <<endl);
+ tmp = m_list.remove_element(tmp);
+ if (tmp)
+ DEBUG("element removed and tmp points on "<<tmp->getItem()->getAlarmId()<<endl);
+ else
+ DEBUG("Last Item erased"<<endl);
+ }
+ else
+ {
+ if (cur.next())
+ tmp = cur.get_cursor();
+ }
+ }*/
+
+
+ }
+
+}
+
+
+
+
+long AlarmList::getAlarmIdCounter()
+{
+ return m_alarmIdCounter;
+}
+
+
+
+void AlarmList::setAlarmIdCounter(long iCounter)
+{
+ m_alarmIdCounter = iCounter;
+}
+
+
+
+
+void AlarmList::increaseIdCounter()
+{
+ ++m_alarmIdCounter;
+}
+
+
+
+void AlarmList::displayAlarmList()
+{
+ agentsnmp::commonOrderedListCursor<AlarmObjectModel> cur;
+
+ for (cur.init(&m_list); cur.get(); cur.next())
+ {
+ DEBUG("AlarmId: "<< cur.get()->getAlarmId() << " / ");
+ DEBUG("Probable Cause: "<< cur.get()->getProbableCause() <<" / ");
+ DEBUG("Managed Obj: "<< cur.get()->getManagedObject() <<" / ");
+ DEBUG("Description: "<< cur.get()->getDescription() << endl);
+ }
+
+}
+
+
+#endif