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_BEHAVIOR_HH
00029 # define OLENA_CORE_BEHAVIOR_HH
00030 # include <oln/core/abstract/behavior.hh>
00031 # include <mlc/type.hh>
00032
00033 namespace oln {
00040
00041 template <class Exact = mlc::final>
00042 class mirror_behavior:
00043 public abstract::behavior<mlc_exact_vt_type(mirror_behavior<Exact>, Exact)>
00044 {
00045 public:
00046 typedef mirror_behavior<Exact> self_type;
00047 typedef mlc_exact_vt_type(self_type, Exact) exact_type;
00048
00049 template <class I>
00050 void adapt_border_impl(oln::abstract::image<I> &im, coord border_size) const
00051 {
00052 im.border_adapt_mirror(border_size);
00053 };
00054 };
00055
00056
00057
00064 template <class T, class Exact = mlc::final>
00065 class value_behavior:
00066 public abstract::behavior<mlc_2_exact_vt_type(value_behavior, T, Exact)>
00067 {
00068 public:
00069 typedef value_behavior<T, Exact> self_type;
00070 typedef mlc_exact_vt_type(self_type, Exact) exact_type;
00071 typedef T value_type;
00072
00073 explicit value_behavior(value_type value): value_(value)
00074 {
00075 };
00076
00077 template <class I>
00078 void adapt_border_impl(abstract::image<I> &im, coord border_size) const
00079 {
00080 im.border_adapt_assign(border_size, ntg::cast::force<oln_value_type(I)>(value_));
00081 };
00082
00083 protected:
00084 value_type value_;
00085 };
00086
00087
00088
00095 template <class Exact = mlc::final>
00096 class replicate_behavior:
00097 public abstract::behavior<mlc_exact_vt_type(replicate_behavior<Exact>, Exact)>
00098 {
00099 public:
00100 typedef replicate_behavior<Exact> self_type;
00101 typedef mlc_exact_vt_type(self_type, Exact) exact_type;
00102
00103 template <class I>
00104 void adapt_border_impl(abstract::image<I> &im, coord border_size) const
00105 {
00106 im.border_adapt_copy(border_size);
00107 };
00108 };
00109
00110
00112 inline mirror_behavior<> mirror_bhv()
00113 {
00114 return mirror_behavior<>();
00115 }
00116
00118 template <class T>
00119 inline value_behavior<T> value_bhv(const T &value)
00120 {
00121 return value_behavior<T>(value);
00122 }
00123
00125 inline replicate_behavior<> replicate_bhv()
00126 {
00127 return replicate_behavior<>();
00128 }
00129 }
00130
00131 #endif // !OLN_CORE_BEHAVIOR_HH