00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the bit library. * 00006 * * 00007 * The bit library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The bit library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef BITRECORDBASE_H 00020 #define BITRECORDBASE_H 00021 00022 #include <bit/fieldbase.h> 00023 00024 namespace bit { 00025 00032 class RecordBase : public FieldBase 00033 { 00034 public: 00035 typedef BitPointer<RecordBase> pointer; 00036 00037 RecordBase( std::string name="", 00038 size_t length_units=BITS, 00039 int offset=0, 00040 size_t offset_units=BITS, 00041 std::string descr="" 00042 ); 00043 00044 virtual ~RecordBase(); 00045 00046 virtual size_t length_units() const; 00047 00048 virtual void set_length_units(size_t units); 00049 00051 virtual int offset() const; 00052 00053 virtual int offset(size_t units) const; 00054 00055 virtual void set_offset(int offset); 00056 00057 virtual size_t offset_units() const; 00058 00059 virtual void set_offset_units(size_t units); 00060 00068 virtual std::string name() const; 00069 00070 virtual std::string name(int depth) const; 00071 00073 virtual void set_name(const std::string& name); 00074 00078 virtual std::string description() const; 00079 00081 virtual void set_description(const std::string& description); 00082 00083 virtual void add_field(FieldBase::pointer child) = 0; 00084 00085 virtual void remove_field(const std::string& name) = 0; 00086 00088 virtual const FieldType& type() const; 00089 00091 virtual void set_type( const FieldType& ); 00092 00099 virtual Encoding encoding() const; 00100 00102 virtual void set_encoding( Encoding en ); 00103 00104 protected: 00105 std::string m_name; 00106 size_t m_length_units; 00107 int m_offset; 00108 size_t m_offset_units; 00109 std::string m_description; 00110 FieldType m_type; 00111 Encoding m_encoding; 00112 00113 }; 00114 00115 } 00116 00117 #endif