Back to index

nux  3.0.0
PropertyOperators.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright 2011 Inalogic® Inc.
00004  *
00005  * This program is free software: you can redistribute it and/or modify it
00006  * under the terms of the GNU Lesser General Public License, as
00007  * published by the  Free Software Foundation; either version 2.1 or 3.0
00008  * of the License.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranties of
00012  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00013  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00014  * License for more details.
00015  *
00016  * You should have received a copy of both the GNU Lesser General Public
00017  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00018  *
00019  * Authored by: Tim Penhey <tim.penhey@canonical.com>
00020  *
00021  */
00022 
00023 #if defined(NUX_OS_WINDOWS)
00024   #pragma warning(disable : 4519) // error C4519: default template arguments are only allowed on a class template
00025 #endif
00026 
00027 #ifndef NUXCORE_PROPERTY_OPERATORS_H
00028 #define NUXCORE_PROPERTY_OPERATORS_H
00029 
00030 namespace nux {
00031 
00048 // operator ==
00049 
00050 template <template <typename T> class PROP_TYPE,
00051           typename VALUE_TYPE,
00052           typename TEST_TYPE,
00053           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00054 inline bool operator ==(TEST_TYPE const& lhs,
00055                         PROP_TYPE<VALUE_TYPE> const& rhs)
00056 {
00057   return lhs == rhs();
00058 }
00059 
00060 template <template <typename T> class PROP_TYPE,
00061           typename VALUE_TYPE,
00062           typename TEST_TYPE,
00063           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00064 inline bool operator ==(PROP_TYPE<VALUE_TYPE> const& lhs,
00065                         TEST_TYPE const& rhs)
00066 {
00067   return lhs() == rhs;
00068 }
00069 
00070 template <template <typename T> class PROP_TYPE,
00071           typename VALUE_TYPE,
00072           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00073 inline bool operator ==(PROP_TYPE<VALUE_TYPE> const& lhs,
00074                         PROP_TYPE<VALUE_TYPE> const& rhs)
00075 {
00076   return lhs() == rhs();
00077 }
00078 
00079 // operator !=
00080 
00081 template <template <typename T> class PROP_TYPE,
00082           typename VALUE_TYPE,
00083           typename TEST_TYPE,
00084           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00085 inline bool operator !=(TEST_TYPE const& lhs,
00086                         PROP_TYPE<VALUE_TYPE> const& rhs)
00087 {
00088   return lhs != rhs();
00089 }
00090 
00091 template <template <typename T> class PROP_TYPE,
00092           typename VALUE_TYPE,
00093           typename TEST_TYPE,
00094           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00095 inline bool operator !=(PROP_TYPE<VALUE_TYPE> const& lhs,
00096                         TEST_TYPE const& rhs)
00097 {
00098   return lhs() != rhs;
00099 }
00100 
00101 template <template <typename T> class PROP_TYPE,
00102           typename VALUE_TYPE,
00103           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00104 inline bool operator !=(PROP_TYPE<VALUE_TYPE> const& lhs,
00105                         PROP_TYPE<VALUE_TYPE> const& rhs)
00106 {
00107   return lhs() != rhs();
00108 }
00109 
00110 // operator <
00111 
00112 template <template <typename T> class PROP_TYPE,
00113           typename VALUE_TYPE,
00114           typename TEST_TYPE,
00115           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00116 inline bool operator <(TEST_TYPE const& lhs,
00117                        PROP_TYPE<VALUE_TYPE> const& rhs)
00118 {
00119   return lhs < rhs();
00120 }
00121 
00122 template <template <typename T> class PROP_TYPE,
00123           typename VALUE_TYPE,
00124           typename TEST_TYPE,
00125           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00126 inline bool operator <(PROP_TYPE<VALUE_TYPE> const& lhs,
00127                        TEST_TYPE const& rhs)
00128 {
00129   return lhs() < rhs;
00130 }
00131 
00132 template <template <typename T> class PROP_TYPE,
00133           typename VALUE_TYPE,
00134           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00135 inline bool operator <(PROP_TYPE<VALUE_TYPE> const& lhs,
00136                        PROP_TYPE<VALUE_TYPE> const& rhs)
00137 {
00138   return lhs() < rhs();
00139 }
00140 
00141 // operator <=
00142 
00143 template <template <typename T> class PROP_TYPE,
00144           typename VALUE_TYPE,
00145           typename TEST_TYPE,
00146           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00147 inline bool operator <=(TEST_TYPE const& lhs,
00148                         PROP_TYPE<VALUE_TYPE> const& rhs)
00149 {
00150   return lhs <= rhs();
00151 }
00152 
00153 template <template <typename T> class PROP_TYPE,
00154           typename VALUE_TYPE,
00155           typename TEST_TYPE,
00156           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00157 inline bool operator <=(PROP_TYPE<VALUE_TYPE> const& lhs,
00158                         TEST_TYPE const& rhs)
00159 {
00160   return lhs() <= rhs;
00161 }
00162 
00163 template <template <typename T> class PROP_TYPE,
00164           typename VALUE_TYPE,
00165           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00166 inline bool operator <=(PROP_TYPE<VALUE_TYPE> const& lhs,
00167                         PROP_TYPE<VALUE_TYPE> const& rhs)
00168 {
00169   return lhs() <= rhs();
00170 }
00171 
00172 // operator >
00173 
00174 template <template <typename T> class PROP_TYPE,
00175           typename VALUE_TYPE,
00176           typename TEST_TYPE,
00177           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00178 inline bool operator >(TEST_TYPE const& lhs,
00179                        PROP_TYPE<VALUE_TYPE> const& rhs)
00180 {
00181   return lhs > rhs();
00182 }
00183 
00184 template <template <typename T> class PROP_TYPE,
00185           typename VALUE_TYPE,
00186           typename TEST_TYPE,
00187           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00188 inline bool operator >(PROP_TYPE<VALUE_TYPE> const& lhs,
00189                        TEST_TYPE const& rhs)
00190 {
00191   return lhs() > rhs;
00192 }
00193 
00194 template <template <typename T> class PROP_TYPE,
00195           typename VALUE_TYPE,
00196           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00197 inline bool operator >(PROP_TYPE<VALUE_TYPE> const& lhs,
00198                        PROP_TYPE<VALUE_TYPE> const& rhs)
00199 {
00200   return lhs() > rhs();
00201 }
00202 
00203 // operator >=
00204 
00205 template <template <typename T> class PROP_TYPE,
00206           typename VALUE_TYPE,
00207           typename TEST_TYPE,
00208           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00209 inline bool operator >=(TEST_TYPE const& lhs,
00210                         PROP_TYPE<VALUE_TYPE> const& rhs)
00211 {
00212   return lhs >= rhs();
00213 }
00214 
00215 template <template <typename T> class PROP_TYPE,
00216           typename VALUE_TYPE,
00217           typename TEST_TYPE,
00218           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00219 inline bool operator >=(PROP_TYPE<VALUE_TYPE> const& lhs,
00220                         TEST_TYPE const& rhs)
00221 {
00222   return lhs() >= rhs;
00223 }
00224 
00225 template <template <typename T> class PROP_TYPE,
00226           typename VALUE_TYPE,
00227           typename VT = typename PROP_TYPE<VALUE_TYPE>::ValueType>
00228 inline bool operator >=(PROP_TYPE<VALUE_TYPE> const& lhs,
00229                         PROP_TYPE<VALUE_TYPE> const& rhs)
00230 {
00231   return lhs() >= rhs();
00232 }
00233 
00234 }
00235 
00236 #endif