1 // Copyright (C) 2013 CEA/DEN, EDF R&D
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.
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__
26 #include "XAO_Exception.hxx"
27 #include "XAO_XaoUtils.hxx"
28 #include "XAO_Geometry.hxx"
41 * The Xao class describes the XAO format.
47 * Default constructor.
51 * Constructor with author and version.
52 * \param author the author of the file.
53 * \param version the version of the XAO format.
55 Xao(const std::string& author, const std::string& version);
62 * Gets the author of the file.
63 * \return the author of the file.
65 const std::string getAuthor() const
70 * Sets the author of the file.
71 * \param author the author to set.
73 void setAuthor(const std::string& author)
79 * Gets the version of the file.
80 * \return the version of the file.
82 const std::string getVersion() const
87 * Sets the version of the file.
88 * \param version the version to set.
90 void setVersion(const std::string& version)
101 * \return the geometry.
103 Geometry* getGeometry() const
109 * \param geometry the geometry to set.
111 void setGeometry(Geometry* geometry) throw (XAO_Exception)
113 if (m_geometry != NULL)
114 throw XAO_Exception("Geometry already set.");
115 m_geometry = geometry;
116 m_geometry->setReadOnly();
124 * Gets the number of groups.
125 * \return the number of groups.
127 const int countGroups() const;
130 * \param index the index of the wanted group.
133 Group* getGroup(const int& index) throw (XAO_Exception);
136 * \param dim the dimension of the group.
137 * \param name the name of the group.
138 * \return the created group.
140 Group* addGroup(const XAO::Dimension& dim, const std::string& name = std::string("")) throw (XAO_Exception);
143 * \param group the group to remove.
144 * \return true if the group has been removed, false otherwise.
146 bool removeGroup(Group* group);
153 * Gets the number of fields.
154 * \return the number of fields.
156 const int countFields() const;
159 * Gets the type of a field.
160 * \param index the index of the wanted field.
161 * \return the type of the field.
163 const XAO::Type getFieldType(const int& index) throw (XAO_Exception);
167 * \param index the index of the wanted field.
170 Field* getField(const int& index) throw (XAO_Exception);
172 BooleanField* getBooleanField(const int& index) throw (XAO_Exception);
173 DoubleField* getDoubleField(const int& index) throw (XAO_Exception);
174 IntegerField* getIntegerField(const int& index) throw (XAO_Exception);
175 StringField* getStringField(const int& index) throw (XAO_Exception);
179 * \param type the type of the field.
180 * \param dim the dimension of the field.
181 * \param nbComponents the number of components in the field.
182 * \param name the name of the field.
183 * \return the created field.
185 Field* addField(const XAO::Type& type, const XAO::Dimension& dim, const int& nbComponents,
186 const std::string& name = std::string(""))
187 throw (XAO_Exception);
189 BooleanField* addBooleanField(const XAO::Dimension& dim, const int& nbComponents,
190 const std::string& name = std::string("")) throw (XAO_Exception);
191 IntegerField* addIntegerField(const XAO::Dimension& dim, const int& nbComponents,
192 const std::string& name = std::string("")) throw (XAO_Exception);
193 DoubleField* addDoubleField(const XAO::Dimension& dim, const int& nbComponents,
194 const std::string& name = std::string("")) throw (XAO_Exception);
195 StringField* addStringField(const XAO::Dimension& dim, const int& nbComponents,
196 const std::string& name = std::string("")) throw (XAO_Exception);
200 * \param field the field to remove.
201 * \return true if the field has been removed, false otherwise.
203 bool removeField(Field* field);
209 * Exports this XAO object to a file.
210 * \param fileName the name of the file to create.
211 * \return true is the export is successful.
213 const bool exportXAO(const std::string& fileName);
215 * Gets the XML corresponding to this XAO.
216 * \return the XML as a string.
218 const std::string getXML();
221 * Imports an XAO file into this object.
222 * \param fileName the name of the file to import.
223 * \return true if the import is successful.
225 const bool importXAO(const std::string& fileName);
227 * Sets an XML describing an XAO format to this object.
228 * \param xml the XML to set.
229 * \return true if the import is successful.
231 const bool setXML(const std::string& xml);
234 void checkGeometry() const throw (XAO_Exception);
235 void checkGroupIndex(const int& index) const throw (XAO_Exception);
236 void checkFieldIndex(const int& index) const throw (XAO_Exception);
237 void checkGroupDimension(const XAO::Dimension& dim) const throw (XAO_Exception);
240 /** The author of the file. */
241 std::string m_author;
242 /** The version of the file. */
243 std::string m_version;
245 Geometry* m_geometry;
246 /** The list of groups. */
247 std::list<Group*> m_groups;
248 /** The list of fields. */
249 std::list<Field*> m_fields;