Updated license
[anna.git] / include / anna / core / oam / Handler.hpp
1 // ANNA - Anna is Not Nothingness 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 #include <cstdarg>
49
50
51 namespace anna {
52
53 namespace oam {
54
55 class Module;
56
57
58 /**
59 * Class used to manage OAM events and registration over a OAM module
60 */
61 class Handler {
62
63 protected:
64
65   /**
66   * Event for counters generated at the module provided. Base implementation trace the event based on #Module::getDefaultCounterDescription.
67   *
68   * Any re-implementation should invoke base class method.
69   *
70   * @param module Reference OAM module.
71   * @param type Counter enum-identification within the own context/module.
72   * @param amount Units increased.
73   *
74   * @return Boolean counter data for 'type' when registered, NULL if not found
75   */
76   virtual const counter_data_t *counterEvent(const Module *module, const int & type, const int & amount) const throw();
77
78   /**
79   * Event for alarms generated at the module provided. Base implementation trace the event based on #Module::getDefaultAlarmDescription,
80   * replacing tags '__s__' and '__d__' by '<\%s>' and '<\%d>' (for texts and numbers) if they exists, and parsing with
81   * dynamic variables passed on activateAlarm()/cancelAlarm() prototypes.
82   *
83   * Any re-implementation should invoke base class method.
84   *
85   * @param module Reference OAM module.
86   * @param textPreffix Dynamic alarm modification regarding text preffix.
87   * @param textSuffix Dynamic alarm modification regarding text suffix.
88   * @param textSeparator Dynamic alarm modification regarding text sections separator.
89   * @param Activation activation/cancellation indicator.
90   * @param type Alarm enum-identification within the own context/module.
91   * @param argList Optional parsing data for dynamic-composed text.
92   *
93   * @return Boolean alarm data for 'type' when registered, NULL if not found
94   */
95   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();
96
97
98 public:
99
100   /**
101    * Constructor
102    */
103   Handler() {;}
104
105   /**
106    * Destructor
107    */
108   ~Handler() {;}
109
110
111   /**
112   * Invokes module counter registration procedure.
113   * Default implementation does nothing specific
114   *
115   * @param module Reference OAM module
116   * @see #anna::oam::Module::registerCounter
117   */
118   virtual void registerCounter(Module *module, const int &type, const std::string &description, const int &offset) throw(anna::RuntimeException) {;}
119
120   /**
121   * Invokes module alarm registration procedure.
122   * Default implementation does nothing specific
123   *
124   * @param module Reference OAM module
125   * @see #anna::oam::Module::registerAlarm
126   */
127   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) {;}
128
129
130   friend class Module;
131 };
132
133 }
134 }
135
136 #endif
137