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(const oln::abstract::image<I> &im,
00051 coord border_size) const
00052 {
00053 im.border_adapt_mirror(border_size);
00054 }
00055 };
00056
00057
00058
00065 template <class T, class Exact = mlc::final>
00066 class value_behavior:
00067 public abstract::behavior<mlc_2_exact_vt_type(value_behavior, T, Exact)>
00068 {
00069 public:
00070 typedef value_behavior<T, Exact> self_type;
00071 typedef mlc_exact_vt_type(self_type, Exact) exact_type;
00072 typedef T value_type;
00073
00074 explicit value_behavior(value_type value): value_(value)
00075 {
00076 };
00077
00078 template <class I>
00079 void adapt_border_impl(const abstract::image<I> &im,
00080 coord border_size) const
00081 {
00082 im.border_adapt_assign(border_size,
00083 ntg::cast::force<oln_value_type(I)>(value_));
00084 }
00085
00087 value_behavior() {}
00088
00089 protected:
00090 value_type value_;
00091 };
00092
00093
00094
00101 template <class Exact = mlc::final>
00102 class replicate_behavior:
00103 public abstract::behavior<mlc_exact_vt_type(replicate_behavior<Exact>, Exact)>
00104 {
00105 public:
00106 typedef replicate_behavior<Exact> self_type;
00107 typedef mlc_exact_vt_type(self_type, Exact) exact_type;
00108
00109 template <class I>
00110 void adapt_border_impl(const abstract::image<I> &im,
00111 coord border_size) const
00112 {
00113 im.border_adapt_copy(border_size);
00114 }
00115
00116 };
00117
00118
00120 inline mirror_behavior<> mirror_bhv()
00121 {
00122 return mirror_behavior<>();
00123 }
00124
00126 template <class T>
00127 inline value_behavior<T> value_bhv(const T &value)
00128 {
00129 return value_behavior<T>(value);
00130 }
00131
00133 inline replicate_behavior<> replicate_bhv()
00134 {
00135 return replicate_behavior<>();
00136 }
00137 }
00138
00139 #endif // !OLN_CORE_BEHAVIOR_HH