1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
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 //
9 #ifndef anna_diameter_stack_AvpRule_hpp
10 #define anna_diameter_stack_AvpRule_hpp
14 #include <anna/diameter/defines.hpp>
16 #include <anna/core/RuntimeException.hpp>
17 #include <anna/core/define.autoenum.hpp>
25 #define DICTIONARY_AVPRULE_TAB " "
45 //------------------------------------------------------------------------------
46 //---------------------------------------------------------------- class AvpRule
47 //------------------------------------------------------------------------------
49 * Avp rule information
63 anna_declare_enum(Presence);
66 * Presence description
67 * @param v Presence type
68 * @return Presence description
70 static const char* asText(const Presence::_v v) throw(anna::RuntimeException) {
77 const Dictionary *a_dictionary;
78 AvpId a_avpId; // reference
79 Presence::_v a_presence;
82 void _initialize(const Dictionary *d) throw() {
84 a_presence = Presence::None;
91 AvpRule(const Dictionary *d = NULL) { _initialize(d); }
96 std::string getAvpName(void) const throw();
97 const Presence::_v & getPresence(void) const throw() { return a_presence; }
98 const std::string & getQual(void) const throw() { return a_qual; }
101 AvpId getId(void) const throw() { return a_avpId; }
102 bool isAny(void) const throw(); // generic Avp
103 bool isFixed(void) const throw() { return (a_presence == Presence::Fixed); }
104 bool isMandatory(void) const throw() { return (a_presence == Presence::Mandatory); }
105 bool isOptional(void) const throw() { return (a_presence == Presence::Optional); }
106 int getQualMin(void) const throw();
107 int getQualMax(void) const throw(); // -1 is infinite
109 std::string asString(bool showPair = true) const throw();
110 anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
115 void initialize(const Dictionary *d = NULL) throw() { _initialize(d); }
116 void setAvpId(const AvpId & ai) throw() { a_avpId = ai; }
117 void setPresence(const Presence::_v & p) throw() { a_presence = p; }
118 void setQual(const std::string & q) throw(anna::RuntimeException);