00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #ifndef BTK_ATOM_CONTAINER_H
00026 #define BTK_ATOM_CONTAINER_H
00027
00028 #include "atom.h"
00029 #include "atom_group_concept.h"
00030 #include "group_types.h"
00031 #include "shared_vector_base.h"
00032
00033 #include <boost/concept_check.hpp>
00034
00035 namespace BTK {
00036
00043 template <typename AtomType>
00044 class AtomContainer : public SharedVectorBase<AtomType>, public AtomGroupConcept {
00045 BOOST_CLASS_REQUIRE2( AtomType, Atom, boost, ConvertibleConcept);
00046
00047 typedef SharedVectorBase<AtomType> base_type;
00048 typedef AtomGroupConcept group_concept_type;
00049 typedef AtomContainer<AtomType> self_type;
00050 public:
00051
00053
00054 typedef typename base_type::value_type value_type;
00055 typedef typename base_type::reference reference;
00056 typedef typename base_type::const_reference const_reference;
00057 typedef typename base_type::pointer pointer;
00058 typedef typename base_type::const_pointer const_pointer;
00059 typedef typename base_type::size_type size_type;
00060 typedef typename base_type::iterator iterator;
00061 typedef typename base_type::const_iterator const_iterator;
00063
00065
00066 typedef value_type atom_type;
00067 typedef iterator atom_iterator;
00068 typedef const_iterator const_atom_iterator;
00070
00071
00073 AtomContainer(size_type s = 0) : base_type(s), group_concept_type() {}
00074
00075 template <typename AtomIterator>
00076 AtomContainer(AtomIterator first,
00077 AtomIterator last)
00078 : base_type(first,last),
00079 group_concept_type()
00080 {
00081 set_group();
00082 }
00083
00084 AtomContainer(const self_type& source)
00085 : base_type(source),
00086 group_concept_type()
00087 {
00088 set_group();
00089 }
00090
00091 template <typename T2>
00092 AtomContainer(const AtomContainer<T2>& source)
00093 : base_type(source),
00094 group_concept_type()
00095 {
00096 set_group();
00097 }
00098
00099 ~AtomContainer() {}
00100
00101
00103 self_type&
00104 operator=(const self_type& rhs)
00105 {
00106 if (&rhs == this) return *this;
00107 base_type::operator=(rhs);
00108 set_group();
00109 return *this;
00110 }
00111
00112 template <typename T2>
00113 self_type&
00114 operator=(const AtomContainer<T2>& rhs)
00115 {
00116 base_type::operator=(rhs);
00117 set_group();
00118 return *this;
00119 }
00120
00122
00123 virtual
00124 GROUP::index_t
00125 group_index() const
00126 {
00127 return GROUP::UNKNOWN;
00128 }
00129
00130 virtual
00131 const AtomGroupConcept::group_variant_container_t&
00132 group_variant_codes() const
00133 {
00134 static AtomGroupConcept::group_variant_container_t s;
00135 return s;
00136 }
00137
00138 virtual
00139 const std::string&
00140 group_name3() const
00141 {
00142 static std::string s("XXX");
00143 return s;
00144 }
00145
00146 virtual int group_num() const { return 0; }
00147
00148
00151
00152
00153 size_type atom_size() const { return this->size(); }
00154
00155 atom_iterator atom_begin() { return this->begin(); }
00156 const_atom_iterator atom_begin() const { return this->begin(); }
00157
00158 atom_iterator atom_end() { return this->end(); }
00159 const_atom_iterator atom_end() const { return this->end(); }
00160
00161 reference atom(size_type i) { return this->operator[](i); }
00162 const_reference atom(size_type i) const { return this->operator[](i); }
00163
00164 reference atom_back() { return this->back(); }
00165 const_reference atom_back() const { return this->back(); }
00166
00167 reference atom_front() { return this->front(); }
00168 const_reference atom_front() const { return this->front(); }
00170
00171 private:
00172 void
00173 set_group()
00174 {
00175 iterator i=begin(),i_end=end();
00176 for(;i!=i_end;++i) i->set_group(*this);
00177 }
00178 };
00179
00180 }
00181
00182
00183 #endif