debian/libbit-dev/usr/include/bit-0.3/bit/fieldvector.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_FIELDVECTOR_H
00020 #define BIT_FIELDVECTOR_H
00021 
00022 #include <string>
00023 #include <vector>
00024 
00025 #include <libxml++/libxml++.h>
00026 
00027 #include <bit/field.h>
00028 
00029 namespace bit
00030   {
00031 
00040   class FieldVector: public Field
00041     {
00042     public:
00043 
00049     class Element: public FieldBase
00050         {
00051         public:
00052 
00053           typedef BitPointer<Element> pointer;
00054 
00055         protected:
00056 
00057           friend class FieldVector;
00058 
00059           Element(size_t index);
00060 
00061           static Element::pointer create(size_t index);
00062 
00063         public:
00064 
00065           virtual ~Element() { }
00066 
00068           virtual size_t length() const;
00069 
00070           virtual size_t length(size_t units) const;
00071 
00073           virtual size_t length_units() const;
00074 
00076           virtual int offset() const;
00077 
00078           virtual int offset(size_t units) const;
00079 
00084           virtual size_t offset_units() const;
00085 
00093           virtual std::string name() const;
00094 
00095           virtual std::string name(int depth) const;
00096 
00100           virtual std::string description() const;
00101 
00102           virtual const std::string& xml();
00103 
00104           size_t index() const;
00105 
00106           virtual FieldBase::pointer clone();
00107 
00108           virtual Container container_type() { return FIELD_ELEMENT; }
00109 
00110           protected:
00111           size_t m_index;
00112         };
00113 
00114       typedef BitPointer<FieldVector> pointer;
00115 
00128       FieldVector( std::string name="",
00129              size_t size=0,
00130              size_t element_length=0,
00131              size_t element_length_units=BITS,
00132              int offset=0,
00133              size_t offset_units=BITS,
00134              std::string descr=""
00135            );
00136 
00137       static FieldVector::pointer create( std::string name="",
00138                                     size_t size=0,
00139                                     size_t element_length=0,
00140                                     size_t element_length_units=BITS,
00141                                     int offset=0,
00142                                     size_t offset_units=BITS,
00143                                     std::string descr=""
00144                                   );
00145 
00146       virtual ~FieldVector();
00147 
00148       virtual const std::string& xml();
00149 
00150       size_t length() const;
00151 
00152       size_t length(size_t units) const;
00153 
00154       size_t element_length() const;
00155 
00156       size_t size() const;
00157 
00158       void set_size(size_t size);
00159 
00160       virtual iterator begin();
00161 
00162       virtual iterator end();
00163 
00164       virtual FieldBase::pointer field(size_t i);
00165 
00166       virtual FieldBase::pointer clone();
00167 
00168       virtual Container container_type() { return FIELD_VECTOR; }
00169 
00170       protected:
00171       size_t m_size;
00172 
00173       typedef std::vector<Element::pointer> Elements;
00174 
00175       Elements m_elements;
00176 
00177       virtual FieldBase::pointer previous_field(FieldBase::pointer current_field) throw (exception::invalid_container_op);
00178 
00179       virtual FieldBase::pointer next_field(FieldBase::pointer current_field) throw (exception::invalid_container_op);
00180 
00181     };
00182 
00183 }
00184 
00185 #endif

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