bit/field.h

00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef BIT_FIELD_H
00020 #define BIT_FIELD_H
00021 
00022 #include <string>
00023 #include <vector>
00024 
00025 #include <libxml++/libxml++.h>
00026 
00027 #include <bit/fieldbase.h>
00028 
00029 namespace bit
00030   {
00031 
00040   class Field: public FieldBase
00041     {
00042     public:
00043 
00044       typedef BitPointer<Field> pointer;
00045 
00046       Field( std::string name="",
00047              size_t length=0,
00048              size_t length_units=BITS,
00049              int offset=0,
00050              size_t offset_units=BITS,
00051              std::string descr=""
00052            );
00053 
00054       static Field::pointer create( std::string name="",
00055                                     size_t length=0,
00056                                     size_t length_units=BITS,
00057                                     int offset=0,
00058                                     size_t offset_units=BITS,
00059                                     std::string descr=""
00060                                   );
00061 
00062       virtual ~Field();
00063 
00064 //       size_t read(xmlpp::Element& xml_element, size_t last_position);
00065 
00067       virtual size_t length() const;
00068 
00069       virtual size_t length( size_t units ) const;
00070 
00071       virtual void set_length(size_t length);
00072 
00073       virtual size_t length_units() const;
00074 
00075       virtual void set_length_units(size_t units);
00076 
00078       virtual int offset() const;
00079 
00080       virtual int offset( size_t units ) const;
00081 
00082       virtual void set_offset(int offset);
00083 
00084       virtual size_t offset_units() const;
00085 
00086       virtual void set_offset_units(size_t units);
00087 
00095       virtual std::string name() const;
00096 
00097       virtual std::string name(int depth) const;
00098 
00099       virtual void set_name(const std::string& name);
00100 
00104       virtual std::string description() const;
00105 
00106       virtual void set_description(const std::string& description);
00107 
00108       virtual const std::string& xml();
00109 
00110       virtual FieldBase::pointer clone();
00111 
00112       virtual Container container_type() { return FIELD; }
00113 
00114     protected:
00115       std::string m_name;
00116       size_t m_length;
00117       size_t m_length_units;
00118       int m_offset;
00119       size_t m_offset_units;
00120       std::string m_description;
00121     };
00122 
00123 }
00124 
00125 #endif

Generated on Tue Mar 13 20:00:01 2007 by  doxygen 1.5.1