H5Attribute.h

00001 // C++ informative line for the emacs editor: -*- C++ -*-
00002 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00003  * Copyright by The HDF Group.                                               *
00004  * Copyright by the Board of Trustees of the University of Illinois.         *
00005  * All rights reserved.                                                      *
00006  *                                                                           *
00007  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00008  * terms governing use, modification, and redistribution, is contained in    *
00009  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00010  * of the source code distribution tree; Copyright.html can be found at the  *
00011  * root level of an installed copy of the electronic HDF5 document set and   *
00012  * is linked from the top-level documents page.  It can also be found at     *
00013  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00014  * access to either file, you may request a copy from help@hdfgroup.org.     *
00015  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00016 
00017 #ifndef _H5Attribute_H
00018 #define _H5Attribute_H
00019 
00020 #ifndef H5_NO_NAMESPACE
00021 namespace H5 {
00022 #endif
00023 
00024 class H5_DLLCPP Attribute : public AbstractDs, public IdComponent {
00025    public:
00026         // Closes this attribute.
00027         virtual void close();
00028 
00029         // Gets the name of the file, in which this attribute belongs.
00030         H5std_string getFileName() const;
00031 
00032         // Gets the name of this attribute.
00033         ssize_t getName( size_t buf_size, H5std_string& attr_name ) const;
00034         H5std_string getName( size_t buf_size ) const; // returns name, not its length
00035         H5std_string getName() const; // returns name, no argument
00036 
00037         // Gets a copy of the dataspace for this attribute.
00038         virtual DataSpace getSpace() const;
00039 
00040         // Returns the amount of storage size required for this attribute.
00041         virtual hsize_t getStorageSize() const;
00042 
00043         // Returns the in memory size of this attribute's data.
00044         virtual size_t getInMemDataSize() const;
00045 
00046         // Reads data from this attribute.
00047         void read( const DataType& mem_type, void *buf ) const;
00048         void read( const DataType& mem_type, H5std_string& strg ) const;
00049 
00050         // Writes data to this attribute.
00051         void write(const DataType& mem_type, const void *buf ) const;
00052         void write(const DataType& mem_type, const H5std_string& strg ) const;
00053 
00055         virtual H5std_string fromClass () const { return("Attribute"); }
00056 
00057         // Creates a copy of an existing attribute using the attribute id
00058         Attribute( const hid_t attr_id );
00059 
00060         // Copy constructor: makes a copy of an existing Attribute object.
00061         Attribute( const Attribute& original );
00062 
00063         // Default constructor
00064         Attribute();
00065 
00066         // Gets the attribute id.
00067         virtual hid_t getId() const;
00068 
00069         // Destructor: properly terminates access to this attribute.
00070         virtual ~Attribute();
00071 
00072    protected:
00073         // Sets the attribute id.
00074         virtual void p_setId(const hid_t new_id);
00075 
00076    private:
00077         hid_t id;       // HDF5 attribute id
00078 
00079         // This function contains the common code that is used by
00080         // getTypeClass and various API functions getXxxType
00081         // defined in AbstractDs for generic datatype and specific
00082         // sub-types
00083         virtual hid_t p_get_type() const;
00084 
00085         // Reads variable or fixed len strings from this attribute.
00086         void p_read_variable_len(const DataType& mem_type, H5std_string& strg) const;
00087         void p_read_fixed_len(const DataType& mem_type, H5std_string& strg) const;
00088 
00089         // do not inherit H5Object::iterateAttrs
00090         int iterateAttrs() { return 0; }
00091 
00092         // do not inherit H5Object::renameAttr
00093         void renameAttr() {}
00094 };
00095 #ifndef H5_NO_NAMESPACE
00096 }
00097 #endif
00098 #endif