1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // http://redmine.teslayout.com/projects/anna-suite
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
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
17 // * Neither the name of the copyright holder 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.
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.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_core_oam_Configuration_hpp
38 #define anna_core_oam_Configuration_hpp
41 #include <anna/core/Singleton.hpp>
42 #include <anna/core/RuntimeException.hpp>
61 * Class used for general OAM configuration
63 class Configuration : public anna::Singleton <Configuration> {
65 // Post-configuration for the final alarm text used for context data over each module (functionality, logic data, etc.):
66 typedef std::vector<std::string> string_vector_t;
67 string_vector_t a_alarm_text_preffix_components;
68 string_vector_t a_alarm_text_suffix_components;
69 bool a_alarms_preffix_enabled; // Show general alarm preffix
70 bool a_alarms_suffix_enabled; // Show general alarm suffix
73 // Delimiters (zone separator for preffix/text/suffix, and left/right/separator for preffix/suffix):
74 char a_alarm_text_delimiter_zS;
75 std::string a_alarm_text_delimiter_psL;
76 std::string a_alarm_text_delimiter_psS;
77 std::string a_alarm_text_delimiter_psR;
79 const string_vector_t * getAlarmPreffixComponents() const throw() { return (a_alarms_preffix_enabled ? &a_alarm_text_preffix_components : NULL); }
80 const string_vector_t * getAlarmSuffixComponents() const throw() { return (a_alarms_suffix_enabled ? &a_alarm_text_suffix_components : NULL); }
82 void getAlarmTextDelimiters(char & zS, std::string & psL, std::string & psS, std::string & psR) const throw();
85 Configuration(); // private constructor
87 friend class anna::Singleton <Configuration>;
93 * Final detailed alarm text is composed by three parts: preffix, database text and suffix.
94 * To separate these zones, we configure the zone separator (space character by default).
95 * Within preffix/suffix we can configure left, right and separator delimiters (by default,
96 * we use square brackets and pipe):
99 * ------- preffix ------- ------- suffix -------
100 * [ pc1 | pc2 | ... | pcM ] text [ sc1 | sc2 | ... | scN ]
102 * Then, pc[i]/sc[i] are the preffix/suffix components.
103 * Usually, 'pc1' is the application facility name.
104 * Dashes could be used instead of pipe '|' with nice result.
108 * @param zS Zone separator delimiter
109 * @param psL Preffix/Suffix left delimiter
110 * @param psS Preffix/Suffix separator delimiter
111 * @param psR Preffix/Suffix right delimiter
113 void setAlarmTextDelimiters(const char zS, const std::string & psL, const std::string & psS, const std::string & psR) throw();
117 * Optional preffix definition to modify dinamically the alarm texts at context.
118 * This affects to all the management modules. It is usually used on application
119 * start tipically with the facility name, although this information is already
120 * shown at the EG component but easier to identify through that detailed text.
121 * Note that preffix components string should be multilanguage texts.
123 * @param components Preffix components for alarm text
125 void setAlarmPreffixComponents(const std::vector<std::string> & components) throw() { a_alarm_text_preffix_components = components; }
129 * Optional suffix definition to modify dinamically the alarm texts at context.
130 * This affects to all the management modules. It is usually used by application
131 * libraries tipically with the oam module name. However this information could be
132 * only useful for developers, and usually would be set by each oam module.
133 * Note that suffix components string should be multilanguage texts.
135 * @param components Suffix components for alarm text
137 void setAlarmSuffixComponents(const std::vector<std::string> & components) throw() { a_alarm_text_suffix_components = components; }
141 * Show general alarm preffix (enabled by default at constructor).
143 void enableAlarmsPreffix() throw();
147 * Show general alarm suffix (enabled by default at constructor).
149 void enableAlarmsSuffix() throw();
153 * Hide general alarm preffix (enabled by default at constructor).
155 void disableAlarmsPreffix() throw();
159 * Hide general alarm suffix (enabled by default at constructor).
161 void disableAlarmsSuffix() throw();
164 * Class XML representation
166 * @return XML with class content
168 anna::xml::Node* asXML(anna::xml::Node* parent) const throw();