Remove dynamic exceptions
[anna.git] / include / anna / core / oam / Configuration.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_core_oam_Configuration_hpp
10 #define anna_core_oam_Configuration_hpp
11
12
13 #include <anna/core/Singleton.hpp>
14 #include <anna/core/RuntimeException.hpp>
15
16 // STL
17 #include <string>
18 #include <vector>
19
20 namespace anna {
21 namespace xml {
22 class Node;
23 }
24 }
25
26
27 namespace anna {
28
29 namespace oam {
30
31
32 /**
33 * Class used for general OAM configuration
34 */
35 class Configuration : public anna::Singleton <Configuration> {
36
37   // Post-configuration for the final alarm text used for context data over each module (functionality, logic data, etc.):
38   typedef std::vector<std::string> string_vector_t;
39   string_vector_t a_alarm_text_preffix_components;
40   string_vector_t a_alarm_text_suffix_components;
41   bool a_alarms_preffix_enabled;   // Show general alarm preffix
42   bool a_alarms_suffix_enabled;    // Show general alarm suffix
43
44
45   // Delimiters (zone separator for preffix/text/suffix, and left/right/separator for preffix/suffix):
46   char a_alarm_text_delimiter_zS;
47   std::string a_alarm_text_delimiter_psL;
48   std::string a_alarm_text_delimiter_psS;
49   std::string a_alarm_text_delimiter_psR;
50
51   const string_vector_t * getAlarmPreffixComponents() const { return (a_alarms_preffix_enabled ? &a_alarm_text_preffix_components : NULL); }
52   const string_vector_t * getAlarmSuffixComponents() const { return (a_alarms_suffix_enabled ? &a_alarm_text_suffix_components : NULL); }
53
54   void getAlarmTextDelimiters(char & zS, std::string & psL, std::string & psS, std::string & psR) const ;
55
56
57   Configuration(); // private constructor
58
59   friend class anna::Singleton <Configuration>;
60   friend class Module;
61
62 public:
63
64   /**
65   * Final detailed alarm text is composed by three parts: preffix, database text and suffix.
66   * To separate these zones, we configure the zone separator (space character by default).
67   * Within preffix/suffix we can configure left, right and separator delimiters (by default,
68   * we use square brackets and pipe):
69   *
70   * <pre>
71   *      ------- preffix -------        ------- suffix -------
72   *     [ pc1 | pc2 | ... | pcM ] text [ sc1 | sc2 | ... | scN ]
73   *
74   *     Then, pc[i]/sc[i] are the preffix/suffix components.
75   *     Usually, 'pc1' is the application facility name.
76   *     Dashes could be used instead of pipe '|' with nice result.
77   *
78   * </pre>
79   *
80   * @param zS Zone separator delimiter
81   * @param psL Preffix/Suffix left delimiter
82   * @param psS Preffix/Suffix separator delimiter
83   * @param psR Preffix/Suffix right delimiter
84   */
85   void setAlarmTextDelimiters(const char zS, const std::string & psL, const std::string & psS, const std::string & psR) ;
86
87
88   /**
89   * Optional preffix definition to modify dinamically the alarm texts at context.
90   * This affects to all the management modules. It is usually used on application
91   * start tipically with the facility name, although this information is already
92   * shown at the EG component but easier to identify through that detailed text.
93   * Note that preffix components string should be multilanguage texts.
94   *
95   * @param components Preffix components for alarm text
96   */
97   void setAlarmPreffixComponents(const std::vector<std::string> & components) { a_alarm_text_preffix_components = components; }
98
99
100   /**
101   * Optional suffix definition to modify dinamically the alarm texts at context.
102   * This affects to all the management modules. It is usually used by application
103   * libraries tipically with the oam module name. However this information could be
104   * only useful for developers, and usually would be set by each oam module.
105   * Note that suffix components string should be multilanguage texts.
106   *
107   * @param components Suffix components for alarm text
108   */
109   void setAlarmSuffixComponents(const std::vector<std::string> & components) { a_alarm_text_suffix_components = components; }
110
111
112   /**
113   * Show general alarm preffix (enabled by default at constructor).
114   */
115   void enableAlarmsPreffix() ;
116
117
118   /**
119   * Show general alarm suffix (enabled by default at constructor).
120   */
121   void enableAlarmsSuffix() ;
122
123
124   /**
125   * Hide general alarm preffix (enabled by default at constructor).
126   */
127   void disableAlarmsPreffix() ;
128
129
130   /**
131   * Hide general alarm suffix (enabled by default at constructor).
132   */
133   void disableAlarmsSuffix() ;
134
135   /**
136   * Class XML representation
137   *
138   * @return XML with class content
139   */
140   anna::xml::Node* asXML(anna::xml::Node* parent) const ;
141 };
142
143 }
144 }
145
146 #endif
147