Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XAO_Xao.hxx
Go to the documentation of this file.
1 // Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
20 
21 #ifndef __XAO_XAO_HXX__
22 #define __XAO_XAO_HXX__
23 
24 #include <string>
25 #include <list>
26 
27 #include "XAO.hxx"
28 #include "XAO_Exception.hxx"
29 #include "XAO_XaoUtils.hxx"
30 #include "XAO_Geometry.hxx"
31 
32 #ifdef WIN32
33 #pragma warning(disable:4290) // Warning Exception ...
34 #pragma warning(disable:4251) // Warning dll-interface ...
35 #endif
36 
37 namespace XAO
38 {
39  class Group;
40  class Field;
41  class IntegerField;
42  class DoubleField;
43  class BooleanField;
44  class StringField;
45 
51  {
52  public:
56  Xao();
62  Xao(const std::string& author, const std::string& version);
66  virtual ~Xao();
67 
72  const std::string getAuthor() const
73  {
74  return m_author;
75  }
80  void setAuthor(const std::string& author)
81  {
82  m_author = author;
83  }
84 
89  const std::string getVersion() const
90  {
91  return m_version;
92  }
97  void setVersion(const std::string& version)
98  {
99  m_version = version;
100  }
101 
102  //
103  // Geometry
104  //
105 
110  Geometry* getGeometry() const
111  {
112  return m_geometry;
113  }
118  void setGeometry(Geometry* geometry) throw (XAO_Exception)
119  {
120  if (m_geometry != NULL)
121  throw XAO_Exception("Geometry already set.");
122  m_geometry = geometry;
123  m_geometry->setReadOnly();
124  }
125 
126  //
127  // Groups
128  //
129 
134  const int countGroups() const;
140  Group* getGroup(const int& index) throw (XAO_Exception);
147  Group* addGroup(const XAO::Dimension& dim, const std::string& name = std::string("")) throw (XAO_Exception);
153  bool removeGroup(Group* group);
154 
155  //
156  // Fields
157  //
158 
163  const int countFields() const;
164 
170  const XAO::Type getFieldType(const int& index) throw (XAO_Exception);
171 
177  Field* getField(const int& index) throw (XAO_Exception);
178 
179  BooleanField* getBooleanField(const int& index) throw (XAO_Exception);
180  DoubleField* getDoubleField(const int& index) throw (XAO_Exception);
181  IntegerField* getIntegerField(const int& index) throw (XAO_Exception);
182  StringField* getStringField(const int& index) throw (XAO_Exception);
183 
192  Field* addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents,
193  const std::string& name = std::string(""))
194  throw (XAO_Exception);
195 
196  BooleanField* addBooleanField(const XAO::Dimension& dim, const int& nbComponents,
197  const std::string& name = std::string("")) throw (XAO_Exception);
198  IntegerField* addIntegerField(const XAO::Dimension& dim, const int& nbComponents,
199  const std::string& name = std::string("")) throw (XAO_Exception);
200  DoubleField* addDoubleField(const XAO::Dimension& dim, const int& nbComponents,
201  const std::string& name = std::string("")) throw (XAO_Exception);
202  StringField* addStringField(const XAO::Dimension& dim, const int& nbComponents,
203  const std::string& name = std::string("")) throw (XAO_Exception);
204 
210  bool removeField(Field* field);
211 
212  //
213  // Import / Export
214  //
221  const bool exportXAO(const std::string& fileName, const std::string& shapeFileName);
226  const std::string getXML();
227 
233  const bool importXAO(const std::string& fileName);
239  const bool setXML(const std::string& xml);
240 
241  private:
242  void checkGeometry() const throw (XAO_Exception);
243  void checkGroupIndex(const int& index) const throw (XAO_Exception);
244  void checkFieldIndex(const int& index) const throw (XAO_Exception);
245  void checkGroupDimension(const XAO::Dimension& dim) const throw (XAO_Exception);
246 
247  private:
249  std::string m_author;
251  std::string m_version;
253  Geometry* m_geometry;
255  std::list<Group*> m_groups;
257  std::list<Field*> m_fields;
258  };
259 
260 }
261 
262 #endif