Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYSource.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 #if TY_USE_IHM
18 #endif
19 
20 #include "TYSpectre.h"
21 #include "TYSource.h"
22 
24 
26 {
28 
29  _pSpectre = new TYSpectre();
31 }
32 
34 {
35  *this = other;
36 }
37 
39 
41 {
42  if (this != &other)
43  {
44  TYElement::operator=(other);
45  _pSpectre = other._pSpectre;
46  }
47  return *this;
48 }
49 
50 bool TYSource::operator==(const TYSource& other) const
51 {
52  if (this != &other)
53  {
54  if (TYElement::operator!=(other))
55  {
56  return false;
57  }
58  if (_pSpectre != other._pSpectre)
59  {
60  return false;
61  }
62  }
63  return true;
64 }
65 
66 bool TYSource::operator!=(const TYSource& other) const
67 {
68  return !operator==(other);
69 }
70 
71 bool TYSource::deepCopy(const TYElement* pOther, bool copyId /*=true*/, bool pUseCopyTag /*=false*/)
72 {
73  if (!TYElement::deepCopy(pOther, copyId, pUseCopyTag))
74  {
75  return false;
76  }
77 
78  TYSource* pOtherSrc = (TYSource*)pOther;
79 
80  _pSpectre->deepCopy(pOtherSrc->_pSpectre, copyId);
81 
82  return true;
83 }
84 
85 std::string TYSource::toString() const
86 {
87  return "TYSource";
88 }
89 
91 {
92  DOM_Element domNewElem = TYElement::toXML(domElement);
93 
94  return domNewElem;
95 }
96 
98 {
99  TYElement::fromXML(domElement);
100 
101  DOM_Element elemCur;
102  QDomNodeList childs = domElement.childNodes();
103 
104  for (unsigned int i = 0; i < childs.length(); i++)
105  {
106  elemCur = childs.item(i).toElement();
107  if (_pSpectre->callFromXMLIfEqual(elemCur))
108  {
109  _pSpectre->setParent(this);
110  }
111  }
112 
113  return 1;
114 }
QDomElement DOM_Element
Definition: QT2DOM.h:30
outil IHM pour une source (fichier header)
TY_EXTENSION_INST(TYSource)
virtual const char * getClassName() const
Definition: TYElement.h:249
void setType(TYSpectreType type)
Set the spectrum type.
Definition: spectre.h:152
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 int fromXML(DOM_Element domElement)
Definition: TYSource.cpp:97
TYSource()
Definition: TYSource.cpp:25
virtual std::string toString() const
Definition: TYSource.cpp:85
virtual ~TYSource()
Definition: TYSource.cpp:38
TYSource & operator=(const TYSource &other)
Operateur =.
Definition: TYSource.cpp:40
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYSource.cpp:71
bool operator!=(const TYSource &other) const
Operateur !=.
Definition: TYSource.cpp:66
LPTYSpectre _pSpectre
Definition: TYSource.h:96
bool operator==(const TYSource &other) const
Operateur ==.
Definition: TYSource.cpp:50
virtual DOM_Element toXML(DOM_Element &domElement)
Definition: TYSource.cpp:90
virtual bool deepCopy(const TYElement *pOther, bool copyId=true, bool pUseCopyTag=false)
Definition: TYSpectre.cpp:142
@ SPECTRE_TYPE_LW
Definition: spectre.h:30