38 #define G_ACCESS "GModelAssociations::operator[](std::string&)"
39 #define G_AT "GModelAssociations::at(int&)"
40 #define G_SET1 "GModelAssociations::set(int&, GModelAssociation&)"
41 #define G_SET2 "GModelAssociations::set(std::string&, GModelAssociation&)"
42 #define G_APPEND "GModelAssociations::append(GModelAssociation&)"
43 #define G_INSERT1 "GModelAssociations::insert(int&, GModelAssociation&)"
44 #define G_INSERT2 "GModelAssociations::insert(std::string&, "\
46 #define G_REMOVE1 "GModelAssociations::remove(int&)"
47 #define G_REMOVE2 "GModelAssociations::remove(std::string&)"
48 #define G_EXTEND "GModelAssociations::extend(GModelAssociations&)"
49 #define G_READ "GModelAssociations::read(GXml&)"
50 #define G_GET_ASSOCIATION_XML "GModelAssociations::get_association_xml("\
51 "GXmlElement&, std::string&)"
145 if (
this != &associations) {
197 std::string msg =
"Model association \""+name+
"\" not found in "
275 #if defined(G_RANGE_CHECK)
276 if (index < 0 || index >=
size()) {
303 "Attempt to append model association \""+association.
name()+
"\" "
304 "to association container, but an association with the same name "
305 "exists already at index "+
gammalib::str(inx)+
" in the container. "
306 "Every model association in the container needs a unique name.";
337 #if defined(G_RANGE_CHECK)
345 if (index < 0 || index >=
size()) {
356 "Attempt to insert model association \""+association.
name()+
"\" "
357 "in container before index "+
gammalib::str(index)+
", but an "
358 "association with the same name exists already at index "+
359 gammalib::str(inx)+
" in the container. Every model association "
360 "in the container needs a unique name.";
395 std::string msg =
"Model association \""+name+
"\" not found in "
404 "Attempt to insert model association \""+association.
name()+
"\" "
405 "in container before index "+
gammalib::str(index)+
", but an "
406 "association with the same name exists already at index "+
407 gammalib::str(inx)+
" in the container. Every model association "
408 "in the container needs a unique name.";
433 #if defined(G_RANGE_CHECK)
434 if (index < 0 || index >=
size()) {
465 std::string msg =
"Model association \""+name+
"\" not found in "
493 int num = associations.
size();
500 for (
int i = 0; i < num; ++i) {
503 int inx =
get_index(associations[i].name());
506 "Attempt to append model association \""+
507 associations[i].name()+
"\" to container, but an "
508 "association with the same name exists already at "
510 "model association in the container needs a unique name.";
541 return (index != -1);
571 if (xml.
elements(
"associations") > 0) {
577 int n = associations->
elements(
"association");
580 for (
int i = 0; i < n; ++i) {
627 if (xml.
elements(
"associations") == 0) {
635 for (
int i = 0; i <
size(); ++i) {
665 result.append(
"=== GModelAssociations ===");
672 for (
int i = 0; i <
size(); ++i) {
743 for (
int i = 0; i <
size(); ++i) {
774 const std::string& name)
const
783 int n = xml.
elements(
"association");
786 for (
int i = 0; i < n; ++i) {
788 if (element->
attribute(
"name") == name) {
789 association = element;
802 std::string msg =
"Model association \""+name+
"\" not found in XML "
803 " element. Please verify the XML format.";
806 else if (number > 1) {
807 std::string msg =
"Model association \""+name+
"\" found "+
809 " Please verify the XML format.";
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
XML element node class interface definition.
int size(void) const
Return number of associations in container.
#define G_GET_ASSOCIATION_XML
GModelAssociations & operator=(const GModelAssociations &associations)
Assignment operator.
GModelAssociation & insert(const int &index, const GModelAssociation &association)
Insert model association into container.
virtual int elements(void) const
Return number of GXMLElement children of node.
void clear(void)
Clear object.
std::string print(const GChatter &chatter=NORMAL) const
Print model associations.
Model associations container class definition.
void write(GXmlElement &xml) const
Write models into XML element.
bool contains(const std::string &name) const
Signals if model association name exists.
GModelAssociation & append(const GModelAssociation &association)
Append model association to container.
void init_members(void)
Initialise class members.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual ~GModelAssociations(void)
Destructor.
GModelAssociation & operator[](const int &index)
Return reference to association.
void copy_members(const GModelAssociations &associations)
Copy class members.
void remove(const int &index)
Remove model association from container.
GModelAssociations(void)
Void constructor.
int get_index(const std::string &name) const
Return model association index by name.
GModelAssociations * clone(void) const
Clone instance.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
void read(const GXmlElement &xml)
Read model associations from XML document.
bool is_empty(void) const
Signals if there are no associations in container.
Model association class definition.
void reserve(const int &num)
Reserves space for associations in container.
Exception handler interface definition.
Model associations container class.
const std::string & name(void) const
Return association name.
GXmlElement * get_association_xml(GXmlElement &xml, const std::string &name) const
Return pointer to model association with given name in XML element.
std::vector< GModelAssociation > m_associations
List of associations.
void extend(const GModelAssociations &associations)
Append model association container.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
GModelAssociation & at(const int &index)
Return reference to model association.
void free_members(void)
Delete class members.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.