Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYAttenuateur.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
16 /*
17  *
18  */
19 
20 #if TY_USE_IHM
22 #endif
23 
24 #include "Tympan/core/logging.h"
25 
26 #include "TYAttenuateur.h"
27 
29 
31 {
33 
34  _type = 1;
35 
36  _spectreAtt.setType(SPECTRE_TYPE_ATT); // Explicitement spectre d'attenuation
38  _spectreAtt.setParent(this);
39 }
40 
42 {
43  *this = other;
44 }
45 
47 
49 {
50  if (this != &other)
51  {
52  TYElement::operator=(other);
53  _type = other._type;
54  _spectreAtt = other._spectreAtt;
55  }
56  return *this;
57 }
58 
59 bool TYAttenuateur::operator==(const TYAttenuateur& other) const
60 {
61  if (this != &other)
62  {
63  if (TYElement::operator!=(other))
64  {
65  return false;
66  }
67  if (_type != other._type)
68  {
69  return false;
70  }
71  if (_spectreAtt != other._spectreAtt)
72  {
73  return false;
74  }
75  }
76  return true;
77 }
78 
79 bool TYAttenuateur::operator!=(const TYAttenuateur& other) const
80 {
81  return !operator==(other);
82 }
83 
84 bool TYAttenuateur::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
85 {
86  if (!pOther)
87  {
88  return false;
89  }
90  if (!TYElement::deepCopy(pOther, copyId))
91  {
92  return false;
93  }
94 
95  TYAttenuateur* pOtherAtt = (TYAttenuateur*)pOther;
96 
97  _type = pOtherAtt->_type;
98 
99  _spectreAtt.deepCopy(&pOtherAtt->_spectreAtt, copyId);
100 
101  return true;
102 }
103 
104 std::string TYAttenuateur::toString() const
105 {
106  return "TYAttenuateur";
107 }
108 
110 {
111  DOM_Element domNewElem = TYElement::toXML(domElement);
112 
113  TYXMLTools::addElementIntValue(domNewElem, "type", _type);
114 
115  _spectreAtt.toXML(domNewElem);
116 
117  return domNewElem;
118 }
119 
121 {
122  TYElement::fromXML(domElement);
123 
124  bool typeOk = false;
125  DOM_Element elemCur;
126 
127  QDomNodeList childs = domElement.childNodes();
128 
129  for (unsigned int i = 0; i < childs.length(); i++)
130  {
131  elemCur = childs.item(i).toElement();
132 
133  TYXMLTools::getElementIntValue(elemCur, "type", _type, typeOk);
134 
136  }
137 
138  return 1;
139 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
outil IHM pour un attenuateur (fichier header)
TY_EXTENSION_INST(TYAttenuateur)
virtual const char * getClassName() const
Definition: TYElement.h:249
void setType(TYSpectreType type)
Set the spectrum type.
Definition: spectre.h:152
void setDefaultValue(const double &valeur=TY_SPECTRE_DEFAULT_VALUE)
Definition: spectre.cpp:197
bool operator==(const TYAttenuateur &other) const
Operateur ==.
TYAttenuateur & operator=(const TYAttenuateur &other)
Operateur =.
bool operator!=(const TYAttenuateur &other) const
Operateur !=.
virtual std::string toString() const
TYSpectre _spectreAtt
Spectre d'attenuation.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
virtual int fromXML(DOM_Element domElement)
virtual DOM_Element toXML(DOM_Element &domElement)
virtual ~TYAttenuateur()
int _type
Type d'attenuateur.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYElement.cpp:307
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYElement.cpp:368
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
TYElement & operator=(const TYElement &other)
Definition: TYElement.cpp:265
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:544
void setParent(TYElement *pParent)
Definition: TYElement.h:692
virtual int fromXML(DOM_Element domElement)
Definition: TYElement.cpp:381
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYSpectre.cpp:164
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYSpectre.cpp:142
static void addElementIntValue(DOM_Element &parentElem, DOMString nodeName, int nodeValue)
Definition: TYXMLTools.cpp:72
static bool getElementIntValue(DOM_Element parentElem, DOMString nodeName, int &nodeValue)
Definition: TYXMLTools.cpp:129
@ SPECTRE_TYPE_ATT
Definition: spectre.h:28