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_Command_hpp
10 #define anna_diameter_stack_Command_hpp
14 #include <anna/diameter/defines.hpp>
15 #include <anna/diameter/stack/AvpRule.hpp>
16 #include <anna/diameter/codec/Format.hpp>
18 #include <anna/core/RuntimeException.hpp>
19 #include <anna/config/defines.hpp>
42 //------------------------------------------------------------------------------
43 //---------------------------------------------------------------- class Command
44 //------------------------------------------------------------------------------
52 //typedef std::map<AvpId, AvpRule> avprule_container;
53 typedef std::map < int /*position*/, AvpRule > avprule_container;
54 typedef avprule_container::iterator avprule_iterator;
55 typedef avprule_container::const_iterator const_avprule_iterator;
60 const Dictionary *a_dictionary;
65 avprule_container a_avprules;
66 bool a_allowFixedRule;
67 int a_avprulePosition;
69 void _initializeRules() throw() {
71 a_allowFixedRule = true;
72 a_avprulePosition = 0;
75 void _initialize(const Dictionary *d) throw() {
82 Command(const Dictionary *d = NULL) { _initialize(d); }
87 const CommandId & getId(void) const throw() { return a_id; }
88 const std::string & getName(void) const throw() { return a_name; }
92 const_avprule_iterator avprule_begin() const throw() { return a_avprules.begin(); }
93 const_avprule_iterator avprule_end() const throw() { return a_avprules.end(); }
94 int avprule_size() const throw() { return a_avprules.size(); }
98 bool isEmpty(void) const throw() { return (!a_avprules.size()); }
99 bool isRequest(void) const throw() { return (a_id.second); }
100 bool isAnswer(void) const throw() { return (!a_id.second); }
101 bool isChild(const AvpId & avp) const throw();
103 std::string asString(void) const throw();
104 anna::xml::Node* asXML(anna::xml::Node* parent) const throw();
109 void initialize(const Dictionary *d = NULL) throw() { _initialize(d); }
110 void setCode(const U24 & c) throw(anna::RuntimeException) {
114 void setRequest(bool r = true) throw() { a_id.second = r; }
115 void setAnswer(bool a = true) throw() { a_id.second = a; }
116 void setName(const std::string & n) throw(anna::RuntimeException) {
117 if(n == "") throw anna::RuntimeException("Empty command-name string not allowed", ANNA_FILE_LOCATION);
121 void addAvpRule(const AvpRule & avpRule) throw(anna::RuntimeException);