/*************************************************************************** * Copyright (C) 2006 by Fabrice DUCOS * * fabrice.ducos@icare.univ-lille1.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef HDF_VD_FIELD_HPP #define HDF_VD_FIELD_HPP #include #include #include "mfhdf.h" #include "Hdf_attr.hpp" /** * @class Hdf_vd_field represents one vdata field */ class Hdf_vd_field { string name; int32 type; int32 order; int32 size; /** * The VData Field attributes */ vector attrs; /** * @brief retrieve the index of an attribute using its name * @param attr_name the attribute name * @return the attribute index, or -1 if not found */ int32 get_attr_idx(const char* attr_name) const; public: /** * @brief create a VData storage object * @param name the name of the field * @param type the type of the field's datas * @param order the order of the field * @param vd_id the id number of the VData that contains this field * @param field_idx the index of this field in the VData's ones */ Hdf_vd_field(const char *vd_name,const int32 &type, const int32 &order, const int32 &size, const int32 &vd_id=-1, const int32& field_idx=-1); Hdf_vd_field(); Hdf_vd_field(const Hdf_vd_field &hdf_vd); ~Hdf_vd_field(){}; Hdf_vd_field &operator= (const Hdf_vd_field &hdf_vd); std::string get_name() const { return name; } int32 get_type() const { return type; } int32 get_order() const { return order; } int32 get_size() const { return size; } void set_name(const string& name) { this->name = name; } void set_type(const int32& type) { this->type = type; } void set_order(const int32& order) { this->order = order; } void set_size(const int32& size) { this->size = size; } int32 get_nb_attr() const { return attrs.size(); }; /** * @brief access an attribute using its name * @param attr_name the attribute name * @return the attribute. * @throw bad_attribute_name if the attribute doesn't exists */ Hdf_attr get_attribute(const char *attr_name) const; /** * @brief access an attribute using its index * @param attr_idx the attribute index * @return the attribute. * @throw bad_attribute_index if the attribute doesn't exists */ Hdf_attr get_attribute(const int32 &attr_idx) const; /** * @brief test the existence of the attribute * @param attr_name the name of the attribute * @return true if the attribute has been found */ const bool has_attr( const char * attr_name ) const; /** * @brief read the value of an attribute * @param attr_name the name of the attribute * @param value the output value (must be allocated by the caller) * @param ival the index of the attribute value (for array attributes) */ void get_attr_value(const char *attr_name,void *value, int32 ival = 0) const; std::string to_string() const; }; #endif