Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYUserSrcRegime.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 #include "TYUserSrcRegime.h"
17 
19 {
21 
23  _pAtt = NULL;
24  _pDirectivite = NULL;
25 }
26 
28 {
29  *this = other;
30 }
31 
33 {
34  _pAtt = NULL;
35  _pDirectivite = NULL;
36 }
37 
39 {
40  if (this != &other)
41  {
42  TYRegime::operator=(other);
43  if (other._pDirectivite != NULL)
44  {
46  }
47  else
48  {
49  _pDirectivite = NULL;
50  }
51  }
52  return *this;
53 }
54 
56 {
57  if (this != &other)
58  {
59  if (TYRegime::operator!=(other))
60  {
61  return false;
62  }
63  if (_pDirectivite != other._pDirectivite)
64  {
65  return false;
66  }
67  }
68  return true;
69 }
70 
72 {
73  return !operator==(other);
74 }
75 
76 bool TYUserSrcRegime::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
77 {
78  if (!TYRegime::deepCopy(pOther, copyId))
79  {
80  return false;
81  }
82 
83  // TYUserSrcRegime * pOtherRegime = (TYUserSrcRegime *) pOther;
84 
85  if (((TYUserSrcRegime*)pOther)->_pDirectivite != NULL)
86  {
88  _pDirectivite->deepCopy(((TYUserSrcRegime*)pOther)->_pAtt, copyId);
89  }
90  else
91  {
92  _pDirectivite = NULL;
93  }
94 
95  return true;
96 }
97 
98 std::string TYUserSrcRegime::toString() const
99 {
100  return "TYUserSrcRegime";
101 }
102 
104 {
105  DOM_Element domNewElem = TYRegime::toXML(domElement);
106 
107  if (_pDirectivite)
108  {
109  _pDirectivite->toXML(domNewElem);
110  }
111 
112  return domNewElem;
113 }
114 
116 {
117  TYRegime::fromXML(domElement);
118 
119  DOM_Element elemCur;
120 
121  QDomNodeList childs = domElement.childNodes();
122 
123  LPTYDirectivity pDir = new TYDirectivity();
124 
125  for (unsigned int i = 0; i < childs.length(); i++)
126  {
127  elemCur = childs.item(i).toElement();
128  if (pDir->callFromXMLIfEqual(elemCur))
129  {
130  _pDirectivite = pDir;
131  }
132  }
133 
134  return 1;
135 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
virtual const char * getClassName() const
Definition: TYElement.h:249
virtual DOM_Element toXML(DOM_Element &domElement)
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
QString _name
Nom courant de l'element.
Definition: TYElement.h:966
bool callFromXMLIfEqual(DOM_Element &domElement, int *pRetVal=NULL)
Definition: TYElement.cpp:544
QString generateName(const char *classname)
Retourne le nom de la classe associe a un nombre.
static TYNameManager * get()
Retourne l'instance singleton.
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYRegime.cpp:99
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYRegime.cpp:127
TYRegime & operator=(const TYRegime &other)
Operateur =.
Definition: TYRegime.cpp:46
virtual int fromXML(DOM_Element domElement)
Definition: TYRegime.cpp:148
int _typeDistribution
Definition: TYRegime.h:198
@ TY_PUISSANCE_IMPOSEE
Definition: TYRegime.h:190
LPTYAttenuateur _pAtt
Definition: TYRegime.h:200
TYUserSrcRegime & operator=(const TYUserSrcRegime &other)
Operateur =.
virtual DOM_Element toXML(DOM_Element &domElement)
bool operator==(const TYUserSrcRegime &other) const
Operateur ==.
LPTYDirectivity _pDirectivite
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
bool operator!=(const TYUserSrcRegime &other) const
Operateur !=.
virtual int fromXML(DOM_Element domElement)
virtual std::string toString() const
virtual ~TYUserSrcRegime()