1 // Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Nathalie Gore (OpenCascade), Frederic Pons (OpenCascade)
21 #ifndef __XAO_XAO_HXX__
22 #define __XAO_XAO_HXX__
28 #include "XAO_Exception.hxx"
29 #include "XAO_XaoUtils.hxx"
30 #include "XAO_Geometry.hxx"
33 #pragma warning(disable:4290) // Warning Exception ...
34 #pragma warning(disable:4251) // Warning dll-interface ...
48 * The Xao class describes the XAO format.
54 * Default constructor.
58 * Constructor with author and version.
59 * \param author the author of the file.
60 * \param version the version of the XAO format.
62 Xao(const std::string& author, const std::string& version);
69 * Gets the author of the file.
70 * \return the author of the file.
72 const std::string getAuthor() const
77 * Sets the author of the file.
78 * \param author the author to set.
80 void setAuthor(const std::string& author)
86 * Gets the version of the file.
87 * \return the version of the file.
89 const std::string getVersion() const
94 * Sets the version of the file.
95 * \param version the version to set.
97 void setVersion(const std::string& version)
108 * \return the geometry.
110 Geometry* getGeometry() const
116 * \param geometry the geometry to set.
118 void setGeometry(Geometry* geometry) throw (XAO_Exception)
120 if (m_geometry != NULL)
121 throw XAO_Exception("Geometry already set.");
122 m_geometry = geometry;
123 m_geometry->setReadOnly();
131 * Gets the number of groups.
132 * \return the number of groups.
134 const int countGroups() const;
137 * \param index the index of the wanted group.
140 Group* getGroup(const int& index) throw (XAO_Exception);
143 * \param dim the dimension of the group.
144 * \param name the name of the group.
145 * \return the created group.
147 Group* addGroup(const XAO::Dimension& dim, const std::string& name = std::string("")) throw (XAO_Exception);
150 * \param group the group to remove.
151 * \return true if the group has been removed, false otherwise.
153 bool removeGroup(Group* group);
160 * Gets the number of fields.
161 * \return the number of fields.
163 const int countFields() const;
166 * Gets the type of a field.
167 * \param index the index of the wanted field.
168 * \return the type of the field.
170 const XAO::Type getFieldType(const int& index) throw (XAO_Exception);
174 * \param index the index of the wanted field.
177 Field* getField(const int& index) throw (XAO_Exception);
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);
186 * \param type the type of the field.
187 * \param dim the dimension of the field.
188 * \param nbComponents the number of components in the field.
189 * \param name the name of the field.
190 * \return the created field.
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);
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);
207 * \param field the field to remove.
208 * \return true if the field has been removed, false otherwise.
210 bool removeField(Field* field);
216 * Exports this XAO object to a file.
217 * \param fileName the name of the file to create.
218 * \return true is the export is successful.
220 const bool exportXAO(const std::string& fileName);
222 * Gets the XML corresponding to this XAO.
223 * \return the XML as a string.
225 const std::string getXML();
228 * Imports an XAO file into this object.
229 * \param fileName the name of the file to import.
230 * \return true if the import is successful.
232 const bool importXAO(const std::string& fileName);
234 * Sets an XML describing an XAO format to this object.
235 * \param xml the XML to set.
236 * \return true if the import is successful.
238 const bool setXML(const std::string& xml);
241 void checkGeometry() const throw (XAO_Exception);
242 void checkGroupIndex(const int& index) const throw (XAO_Exception);
243 void checkFieldIndex(const int& index) const throw (XAO_Exception);
244 void checkGroupDimension(const XAO::Dimension& dim) const throw (XAO_Exception);
247 /** The author of the file. */
248 std::string m_author;
249 /** The version of the file. */
250 std::string m_version;
252 Geometry* m_geometry;
253 /** The list of groups. */
254 std::list<Group*> m_groups;
255 /** The list of fields. */
256 std::list<Field*> m_fields;