First commit
[anna.git] / include / anna / core / oam / Handler.hpp
1 // ANNA - Anna is Not 'N' Anymore
2 //
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
4 //
5 // https://bitbucket.org/testillano/anna
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 //     * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //     * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
16 // distribution.
17 //     * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
33 // Authors: eduardo.ramos.testillano@gmail.com
34 //          cisco.tierra@gmail.com
35
36
37 #ifndef anna_core_oam_Handler_hpp
38 #define anna_core_oam_Handler_hpp
39
40
41 #include <anna/core/RuntimeException.hpp>
42
43 // STL
44 #include <string>
45
46 #include <anna/core/oam/defines.hpp>
47
48
49 namespace anna {
50
51 namespace oam {
52
53 class Module;
54
55
56 /**
57 * Class used to manage OAM events and registration over a OAM module
58 */
59 class Handler {
60
61 protected:
62
63   /**
64   * Event for counters generated at the module provided. Base implementation trace the event based on #Module::getDefaultCounterDescription.
65   *
66   * Any re-implementation should invoke base class method.
67   *
68   * @param module Reference OAM module.
69   * @param type Counter enum-identification within the own context/module.
70   * @param amount Units increased.
71   *
72   * @return Boolean counter data for 'type' when registered, NULL if not found
73   */
74   virtual const counter_data_t *counterEvent(const Module *module, const int & type, const int & amount) const throw();
75
76   /**
77   * Event for alarms generated at the module provided. Base implementation trace the event based on #Module::getDefaultAlarmDescription,
78   * replacing tags '__s__' and '__d__' by '<\%s>' and '<\%d>' (for texts and numbers) if they exists, and parsing with
79   * dynamic variables passed on activateAlarm()/cancelAlarm() prototypes.
80   *
81   * Any re-implementation should invoke base class method.
82   *
83   * @param module Reference OAM module.
84   * @param textPreffix Dynamic alarm modification regarding text preffix.
85   * @param textSuffix Dynamic alarm modification regarding text suffix.
86   * @param textSeparator Dynamic alarm modification regarding text sections separator.
87   * @param Activation activation/cancellation indicator.
88   * @param type Alarm enum-identification within the own context/module.
89   * @param argList Optional parsing data for dynamic-composed text.
90   *
91   * @return Boolean alarm data for 'type' when registered, NULL if not found
92   */
93   virtual const alarm_data_t *alarmEvent(const Module *module, const char *textPreffix, const char *textSuffix, char textSeparator, bool activation, const int & type, va_list argList) const throw();
94
95
96 public:
97
98   /**
99    * Constructor
100    */
101   Handler() {;}
102
103   /**
104    * Destructor
105    */
106   ~Handler() {;}
107
108
109   /**
110   * Invokes module counter registration procedure.
111   * Default implementation does nothing specific
112   *
113   * @param module Reference OAM module
114   * @see #anna::oam::Module::registerCounter
115   */
116   virtual void registerCounter(Module *module, const int &type, const std::string &description, const int &offset) throw(anna::RuntimeException) {;}
117
118   /**
119   * Invokes module alarm registration procedure.
120   * Default implementation does nothing specific
121   *
122   * @param module Reference OAM module
123   * @see #anna::oam::Module::registerAlarm
124   */
125   virtual void registerAlarm(Module *module, const int &type, const std::string &description, const int &externalId, const std::string &dynamicVariablesCSL, const int &activationId, const int &cancellationId = -1) throw(anna::RuntimeException) {;}
126
127
128   friend class Module;
129 };
130
131 }
132 }
133
134 #endif
135