00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OLENA_CORE_STRUCT_ELT_HH
00029 # define OLENA_CORE_STRUCT_ELT_HH
00030
00031 # include <mlc/type.hh>
00032 # include <oln/core/coord.hh>
00033 # include <oln/core/abstract/dpoint.hh>
00034
00035 namespace oln {
00036
00037 namespace abstract {
00038 template<class Exact>
00039 struct struct_elt;
00040
00041 }
00042
00043 template<class Exact>
00044 struct struct_elt_traits;
00045
00049 template<class Exact>
00050 struct struct_elt_traits<abstract::struct_elt<Exact> >
00051 {
00052 typedef abstract::struct_elt<Exact> abstract_type;
00054 };
00055
00056 namespace abstract {
00057
00064 template<class Exact>
00065 struct struct_elt : public mlc_hierarchy::any< Exact >
00066 {
00067 enum { dim = struct_elt_traits<Exact>::dim };
00069
00070 typedef struct_elt<Exact> self_type;
00072 typedef typename struct_elt_traits<Exact>::abstract_type abstract_type;
00074
00076 static std::string
00077 name()
00078 {
00079 return std::string("struct_elt<") + Exact::name() + ">";
00080 }
00081
00082 typedef typename struct_elt_traits<Exact>::point_type point_type;
00084 typedef typename struct_elt_traits<Exact>::dpoint_type dpoint_type;
00086 typedef Exact exact_type;
00087
00093 bool
00094 has(const abstract::dpoint<dpoint_type>& dp) const
00095 {
00096 return this->exact().has_(dp.exact());
00097 }
00098
00103 unsigned
00104 card() const
00105 {
00106 return this->exact().card_();
00107 }
00108
00115 bool
00116 is_centered() const
00117 {
00118 return this->exact().is_centered_();
00119 }
00120
00129 exact_type&
00130 add(const abstract::dpoint<dpoint_type>& dp)
00131 {
00132 return this->exact().add_dp(dp);
00133 }
00134
00140 dpoint_type
00141 dp(unsigned i) const
00142 {
00143 return this->exact().at(i);
00144 }
00145
00151 bool
00152 operator==(const self_type& win) const
00153 {
00154 return this->exact().is_equal(win.exact());
00155 }
00156
00163 coord
00164 delta() const
00165 {
00166 return this->exact().get_delta();
00167 }
00168
00174 const dpoint_type
00175 operator[](unsigned i) const
00176 {
00177 return this->exact().at(i);
00178 }
00179
00185 exact_type
00186 operator-() const
00187 {
00188 exact_type win(this->exact());
00189 win.sym();
00190 return win;
00191 }
00192
00193 protected:
00194
00200 void
00201 sym()
00202 {
00203 return this->exact().sym_();
00204 }
00205
00209 struct_elt()
00210 {}
00211
00212 };
00213 }
00214
00215 }
00216
00217 #endif // ! OLENA_CORE_STRUCT_ELT_HH