ANNA Suite  2020b
Multipurpose development suite for Telco applications
EngineImpl.hpp
Go to the documentation of this file.
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_diameter_codec_EngineImpl_hpp
10 #define anna_diameter_codec_EngineImpl_hpp
11 
12 
13 // STL
14 #include <string>
15 
17 #include <anna/xml/DTDMemory.hpp>
19 
22 
23 
24 //------------------------------------------------------------------------------
25 //---------------------------------------------------------------------- #define
26 //------------------------------------------------------------------------------
27 
28 
29 namespace anna {
30 
31 namespace diameter {
32 
33 namespace stack {
34 class Dictionary;
35 }
36 
37 namespace codec {
38 
39 class Message;
40 class Avp;
41 
42 
134 class EngineImpl : public anna::Component {
135 
136 public:
137 
141  struct ValidationDepth { enum _v { Complete, FirstError /* default */ }; };
142 
147  struct ValidationMode { enum _v { BeforeEncoding, AfterDecoding /* default */, Always, Never /* optimization */ }; };
148 
158  struct FixMode { enum _v { BeforeEncoding /* default */, AfterDecoding, Always, Never /* optimization */ }; };
159 
160 
161  // Creators
162  Avp* createAvp(const AvpId *id) noexcept(false);
163  Message* createMessage(const CommandId *id) noexcept(false);
164 
165 
166 private:
167 
168  ValidationDepth::_v a_validationDepth;
169  ValidationMode::_v a_validationMode;
170  bool a_singleFailedAVP;
171  bool a_ignoreFlags;
172  FixMode::_v a_fixMode;
173 
174  // Auxiliary
175  const stack::Dictionary * a_dictionary;
176 
177  // helpers
178  static const char* asText(const ValidationDepth::_v) ;
179  static const char* asText(const ValidationMode::_v) ;
180  static const char* asText(const FixMode::_v) ;
181 
182 public:
183 
193  EngineImpl(const char* className, const stack::Dictionary * dictionary);
194 
198  virtual ~EngineImpl() {;}
199 
200 
206  const stack::Dictionary *getDictionary() const { return a_dictionary; }
207 
208 
213  void setValidationDepth(const ValidationDepth::_v validationDepth) { a_validationDepth = validationDepth; }
214 
223  ValidationDepth::_v getValidationDepth() const { return a_validationDepth; }
224 
232  void ignoreFlagsOnValidation(bool ignoreFlags) { a_ignoreFlags = ignoreFlags; }
233 
240  bool ignoreFlagsOnValidation() const { return a_ignoreFlags; }
241 
246  void setValidationMode(const ValidationMode::_v validationMode) { a_validationMode = validationMode; }
247 
254  ValidationMode::_v getValidationMode() const { return a_validationMode; }
255 
256 
257 
262  void setFixMode(const FixMode::_v fixMode) { a_fixMode = fixMode; }
263 
268  FixMode::_v getFixMode() const { return a_fixMode; }
269 
277  void setSingleFailedAVP(bool single = true) { a_singleFailedAVP = single; }
278 
283  bool getSingleFailedAVP() const { return a_singleFailedAVP; }
284 
295  Avp* createAvp(AvpId id) noexcept(false) { return createAvp(&id); }
296 
303  Avp* createAvp() noexcept(false) { return createAvp(NULL); }
304 
315  Message* createMessage(CommandId id) noexcept(false) { return createMessage(&id); }
316 
323  Message* createMessage() noexcept(false) { return createMessage(NULL); }
324 
325 
332  Message *createMessage(const std::string & xmlPathFile_or_string, bool pathfile_or_string = true) noexcept(false);
333 
334 
339  virtual void releaseAvp(Avp*) = 0;
340 
345  virtual void releaseMessage(Message*) = 0;
346 
347 
353  virtual std::string asString(void) const ;
354 
360  virtual anna::xml::Node* asXML(anna::xml::Node* parent) const ;
361 
362 
370  AvpId avpIdForName(const char * name) noexcept(false);
371 
372 
380  CommandId commandIdForName(const char * name) noexcept(false);
381 
382 
383 protected:
384 
392  virtual Avp* allocateAvp() = 0;
393 
394 
402  virtual Message* allocateMessage() = 0;
403 
404 
414  void validationAnomaly(const std::string & description) const noexcept(false);
415 };
416 
417 }
418 }
419 }
420 
421 #endif
422 
Avp * createAvp(AvpId id) noexcept(false)
Definition: EngineImpl.hpp:295
bool ignoreFlagsOnValidation() const
Definition: EngineImpl.hpp:240
void setSingleFailedAVP(bool single=true)
Definition: EngineImpl.hpp:277
void setFixMode(const FixMode::_v fixMode)
Definition: EngineImpl.hpp:262
Definition: Node.hpp:56
Definition: EngineImpl.hpp:158
bool getSingleFailedAVP() const
Definition: EngineImpl.hpp:283
std::pair< S32, S32 > AvpId
Definition: defines.hpp:31
Avp * createAvp() noexcept(false)
Definition: EngineImpl.hpp:303
ValidationMode::_v getValidationMode() const
Definition: EngineImpl.hpp:254
Message * createMessage() noexcept(false)
Definition: EngineImpl.hpp:323
Definition: Avp.hpp:125
_v
Definition: EngineImpl.hpp:158
Definition: Message.hpp:74
Definition: Component.hpp:39
Definition: Dictionary.hpp:50
FixMode::_v getFixMode() const
Definition: EngineImpl.hpp:268
Definition: app.hpp:12
Message * createMessage(CommandId id) noexcept(false)
Definition: EngineImpl.hpp:315
virtual ~EngineImpl()
Definition: EngineImpl.hpp:198
void ignoreFlagsOnValidation(bool ignoreFlags)
Definition: EngineImpl.hpp:232
void setValidationMode(const ValidationMode::_v validationMode)
Definition: EngineImpl.hpp:246
const stack::Dictionary * getDictionary() const
Definition: EngineImpl.hpp:206
std::pair< U24, bool > CommandId
Definition: defines.hpp:32
void setValidationDepth(const ValidationDepth::_v validationDepth)
Definition: EngineImpl.hpp:213
Definition: EngineImpl.hpp:134
Definition: functions.hpp:118
ValidationDepth::_v getValidationDepth() const
Definition: EngineImpl.hpp:223