/*************************************************************************** * Copyright (C) 2005 by Nicolas PASCAL * * nicolas.pascal@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 HDFMETADATANODE_H #define HDFMETADATANODE_H #include #include #include using namespace std; /** Tree node like xml's DOM Tree Node. One node contain one metadata hierarchie level. Computingly talking, it's a binary tree node. A node is define by : - its value (void* to be generic) - the type_code of the value - one next sibling node - one child one @author nicolas PASCAL */ class HDFMetadataNode { public: /** define the type of values that can be found in hdf metadata. FLOAT means double */ enum value_type{ BAD,STRING,INTEGER,FLOAT,ARRAY_INTEGER,ARRAY_FLOAT,ARRAY_STRING, }; /** default constructor */ HDFMetadataNode(); /** * Constructor * @param _value the value of the node * @param _typecode a value_type code representing the type of the node's value */ HDFMetadataNode(void* _value, HDFMetadataNode::value_type _typecode); /** Destructor */ ~HDFMetadataNode(); /** * set the next sibling node * @param val the next sibling node */ void set_next_sibling(HDFMetadataNode* val); /** * access to the next sibling * @return the next sibling (can be NULL) */ HDFMetadataNode* get_next_sibling() const; /** * set the child node * @param val the child node */ void set_child(HDFMetadataNode* val); /** * access to the child node * @return the child node (can be NULL) */ HDFMetadataNode* get_child() const; /** * print out the value of the node */ void print_val() const; /** * Check is a node is a leaf. In other words, if the node has no child and no sibling. * @return true if the node is a leaf. */ const bool is_leaf() const; /** * Fill val with the node value. * @param val (output) the value (or buffer if the node's value is an array) */ void read_node_value(void* val = NULL); /** * access to the type_code of the node's value * @return the type_code of the node's value */ HDFMetadataNode::value_type get_typecode() const; /** * access to the value itself, via a pointer * @return a pointer to the value */ void* get_value() const; private: // the value of the node. If pure Node, NULL void* value; HDFMetadataNode::value_type typecode; HDFMetadataNode* next_sibling; HDFMetadataNode* child; }; #endif