ivl 679
|
00001 /* This file is part of the ivl C++ library <http://image.ntua.gr/ivl>. 00002 A C++ template library extending syntax towards mathematical notation. 00003 00004 Copyright (C) 2012 Yannis Avrithis <iavr@image.ntua.gr> 00005 Copyright (C) 2012 Kimon Kontosis <kimonas@image.ntua.gr> 00006 00007 ivl is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU Lesser General Public License 00009 version 3 as published by the Free Software Foundation. 00010 00011 Alternatively, you can redistribute it and/or modify it under the terms 00012 of the GNU General Public License version 2 as published by the Free 00013 Software Foundation. 00014 00015 ivl is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 See the GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 and a copy of the GNU Lesser General Public License along 00022 with ivl. If not, see <http://www.gnu.org/licenses/>. */ 00023 00024 #ifndef IVL_CORE_DETAILS_TYPES_SCALAR_FPTR_HPP 00025 #define IVL_CORE_DETAILS_TYPES_SCALAR_FPTR_HPP 00026 00027 namespace ivl { 00028 00029 00030 template<class Z, class T, class X1> 00031 class scalar<T (Z::*)(X1) const> : 00032 //public unary_elem_ptr<T, X1>, 00033 public types::scalar_identifier 00034 { 00035 typedef T (Z::*prv_elem_type)(X1) const; 00036 //typedef unary_elem_ptr<T, X1> prv_base; 00037 prv_elem_type prv_base;//@@@ 00038 public: 00039 typedef prv_elem_type elem_type; 00040 scalar() { } 00041 scalar(const scalar& s) : prv_base(s.prv_base) { } 00042 template <class J> 00043 scalar(const scalar<J>& s): prv_base(s) { } 00044 scalar(elem_type s) : prv_base(s) { } 00045 elem_type base() const { return this->prv_base; } 00046 operator elem_type&() const { return this->prv_base; } 00047 scalar& operator=(const scalar& s) { this->prv_base = s.prv_base; return *this; } 00048 scalar& operator=(elem_type s) { this->prv_base = s; return *this; } 00049 template <class J> 00050 scalar& operator=(const J& o) { this->prv_base = o; return *this; } 00051 }; 00052 00053 template<class Z, class T, class X1> 00054 class scalar<T (Z::*)(X1)> : 00055 //public unary_elem_ptr<T, X1>, 00056 public types::scalar_identifier 00057 { 00058 typedef T (Z::*prv_elem_type)(X1); 00059 //typedef unary_elem_ptr<T, X1> prv_base; 00060 prv_elem_type prv_base;//@@@ 00061 public: 00062 typedef prv_elem_type elem_type; 00063 scalar() { } 00064 scalar(const scalar& s) : prv_base(s.prv_base) { } 00065 template <class J> 00066 scalar(const scalar<J>& s): prv_base(s) { } 00067 scalar(elem_type s) : prv_base(s) { } 00068 elem_type base() const { return this->prv_base; } 00069 operator elem_type&() const { return this->prv_base; } 00070 scalar& operator=(const scalar& s) { this->prv_base = s.prv_base; return *this; } 00071 scalar& operator=(elem_type s) { this->prv_base = s; return *this; } 00072 template <class J> 00073 scalar& operator=(const J& o) { this->prv_base = o; return *this; } 00074 }; 00075 // ------------------------------- 00076 00077 template<class T, class X1> 00078 class scalar<T (*)(X1)> : 00079 //public unary_elem_ptr<T, X1>, 00080 public types::scalar_identifier 00081 { 00082 typedef T (*prv_elem_type)(X1); 00083 //typedef unary_elem_ptr<T, X1> prv_base; 00084 prv_elem_type prv_base;//@@@ 00085 public: 00086 typedef prv_elem_type elem_type; 00087 scalar() { } 00088 scalar(const scalar& s) : prv_base(s.val) { } 00089 template <class J> 00090 scalar(const scalar<J>& s): prv_base(s) { } 00091 scalar(elem_type s) : prv_base(s) { } 00092 elem_type& base() const { return this->val; } 00093 operator elem_type&() const { return this->val; } 00094 scalar& operator=(const scalar& s) { this->val = s.val; return *this; } 00095 scalar& operator=(elem_type s) { this->val = s; return *this; } 00096 template <class J> 00097 scalar& operator=(const J& o) { this->val = o; return *this; } 00098 }; 00099 00100 00101 template<class T, class X1> 00102 class scalar<T (&)(X1)> : 00103 //public unary_elem_ptr<T, X1, X2>, 00104 public types::scalar_identifier 00105 { 00106 typedef T (*prv_elem_type)(X1); 00107 //typedef unary_elem_ptr<T, X1> prv_base; 00108 prv_elem_type prv_base; 00109 public: 00110 typedef prv_elem_type elem_type; 00111 scalar() { } 00112 scalar(const scalar& s) : prv_base(s.val) { } 00113 template <class J> 00114 scalar(const scalar<J>& s): prv_base(s) { } 00115 scalar(elem_type s) : prv_base(s) { } 00116 elem_type& base() const { return this->val; } 00117 operator elem_type&() const { return this->val; } 00118 scalar& operator=(const scalar& s) { this->val = s.val; return *this; } 00119 scalar& operator=(elem_type s) { this->val = s; return *this; } 00120 template <class J> 00121 scalar& operator=(const J& o) { this->val = o; return *this; } 00122 }; 00123 00124 00125 00126 00127 // ------------------------------- 00128 00129 template<class T, class X1, class X2> 00130 class scalar<T (*)(X1, X2)> : 00131 public binary_elem_ptr<T, X1, X2>, 00132 public types::scalar_identifier 00133 { 00134 typedef T (*prv_elem_type)(X1, X2); 00135 typedef binary_elem_ptr<T, X1, X2> prv_base; 00136 public: 00137 typedef prv_elem_type elem_type; 00138 scalar() { } 00139 scalar(const scalar& s) : prv_base(s.val) { } 00140 template <class J> 00141 scalar(const scalar<J>& s): prv_base(s) { } 00142 scalar(elem_type s) : prv_base(s) { } 00143 elem_type& base() const { return this->val; } 00144 operator elem_type&() const { return this->val; } 00145 scalar& operator=(const scalar& s) { this->val = s.val; return *this; } 00146 scalar& operator=(elem_type s) { this->val = s; return *this; } 00147 template <class J> 00148 scalar& operator=(const J& o) { this->val = o; return *this; } 00149 }; 00150 00151 00152 template<class T, class X1, class X2> 00153 class scalar<T (&)(X1, X2)> : 00154 public binary_elem_ptr<T, X1, X2>, 00155 public types::scalar_identifier 00156 { 00157 typedef T (*prv_elem_type)(X1, X2); 00158 typedef binary_elem_ptr<T, X1, X2> prv_base; 00159 public: 00160 typedef prv_elem_type elem_type; 00161 scalar() { } 00162 scalar(const scalar& s) : prv_base(s.val) { } 00163 template <class J> 00164 scalar(const scalar<J>& s): prv_base(s) { } 00165 scalar(elem_type s) : prv_base(s) { } 00166 elem_type& base() const { return this->val; } 00167 operator elem_type&() const { return this->val; } 00168 scalar& operator=(const scalar& s) { this->val = s.val; return *this; } 00169 scalar& operator=(elem_type s) { this->val = s; return *this; } 00170 template <class J> 00171 scalar& operator=(const J& o) { this->val = o; return *this; } 00172 }; 00173 00174 } /* namespace ivl */ 00175 00176 #endif // IVL_CORE_DETAILS_TYPES_SCALAR_HPP