Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

PtrFunc.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_Pattern_PtrFunc_h
00002 #define Impala_Core_Array_Pattern_PtrFunc_h
00003 
00004 #include "Basis/NativeTypes.h"
00005 #include "Core/Array/Element/ArithTypes.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Array
00012 {
00013 namespace Pattern
00014 {
00015 
00016 
00017 /*
00018 template <class ArithT, class StorT>
00019 inline ArithT
00020 PtrRead(StorT* ptr, ArithT)
00021 {
00022     return *ptr;
00023 }
00024 */
00025 
00026 inline Int32
00027 PtrRead(Int8* ptr, Int32)
00028 {
00029     return *ptr;
00030 }
00031 
00032 inline Int32
00033 PtrRead(UInt8* ptr, Int32)
00034 {
00035     return *ptr;
00036 }
00037 
00038 inline Int32
00039 PtrRead(Int32* ptr, Int32)
00040 {
00041     return *ptr;
00042 }
00043 
00044 inline UInt64
00045 PtrRead(UInt64* ptr, UInt64)
00046 {
00047     return *ptr;
00048 }
00049 
00050 inline Real64
00051 PtrRead(Real64* ptr, Real64)
00052 {
00053     return *ptr;
00054 }
00055 
00056 inline Element::Vec3Int32
00057 PtrRead(UInt8* ptr, Element::Vec3Int32)
00058 {
00059     return Element::Vec3Int32(ptr[0], ptr[1], ptr[2]);
00060 }
00061 
00062 inline Element::Vec2Real64
00063 PtrRead(Real64* ptr, Element::Vec2Real64)
00064 {
00065     return Element::Vec2Real64(ptr[0], ptr[1]);
00066 }
00067 
00068 inline Element::Vec3Real64
00069 PtrRead(Real64* ptr, Element::Vec3Real64)
00070 {
00071     return Element::Vec3Real64(ptr[0], ptr[1], ptr[2]);
00072 }
00073 
00074 inline Element::Complex64
00075 PtrRead(Real64* ptr, Element::Complex64)
00076 {
00077     return Element::Complex64(ptr[0], ptr[1]);
00078 }
00079 
00080 /* This kind of template class with specialization is too diffucult for VC6
00081 template <class ArrayT>
00082 inline void
00083 PtrWrite(typename ArrayT::StorType* ptr, typename ArrayT::ArithType v)
00084 {
00085     *ptr = v;
00086 }
00087 
00088 // Specialization for ArrayVec3Real64
00089 template <>
00090 inline void
00091 PtrWrite<Array2dVec3Real64>(Real64* ptr, Element::Vec3Real64 v)
00092 {
00093     *ptr++ = v.X();
00094     *ptr++ = v.Y();
00095     *ptr++ = v.Z();
00096 }
00097 */
00098 
00099 inline void
00100 PtrWrite(Int8* ptr, Int32 v)
00101 {
00102     *ptr = v;
00103 }
00104 
00105 inline void
00106 PtrWrite(UInt8* ptr, Int32 v)
00107 {
00108     *ptr = v;
00109 }
00110 
00111 inline void
00112 PtrWrite(Int32* ptr, Int32 v)
00113 {
00114     *ptr = v;
00115 }
00116 
00117 inline void
00118 PtrWrite(UInt64* ptr, UInt64 v)
00119 {
00120     *ptr = v;
00121 }
00122 
00123 inline void
00124 PtrWrite(Real64* ptr, Real64 v)
00125 {
00126     *ptr = v;
00127 }
00128 
00129 inline void
00130 PtrWrite(UInt8* ptr, const Element::Vec3Int32& v)
00131 {
00132     *ptr++ = v.X();
00133     *ptr++ = v.Y();
00134     *ptr++ = v.Z();
00135 }
00136 
00137 inline void
00138 PtrWrite(Int32* ptr, const Element::Vec3Int32& v)
00139 {
00140     *ptr++ = v.X();
00141     *ptr++ = v.Y();
00142     *ptr++ = v.Z();
00143 }
00144 
00145 inline void
00146 PtrWrite(Real64* ptr, const Element::Vec2Real64& v)
00147 {
00148     *ptr++ = v.X();
00149     *ptr++ = v.Y();
00150 }
00151 
00152 inline void
00153 PtrWrite(Real64* ptr, const Element::Vec3Real64& v)
00154 {
00155     *ptr++ = v.X();
00156     *ptr++ = v.Y();
00157     *ptr++ = v.Z();
00158 }
00159 
00160 inline void
00161 PtrWrite(Real64* ptr, const Element::Complex64& v)
00162 {
00163     *ptr++ = v.X();
00164     *ptr++ = v.Y();
00165 }
00166 
00167 /*
00168 template <class ElemT, int vecSize>
00169 inline void
00170 PtrWrite(ElemT* ptr, const VecN<ElemT,vecSize>& v)
00171 {
00172     for (int i=0 ; i<vecSize ; i++)
00173         *ptr++ = v[i];
00174 }
00175 */
00176 
00177 } // namespace Pattern
00178 } // namespace Array
00179 } // namespace Core
00180 } // namespace Impala
00181 
00182 #endif

Generated on Fri Mar 19 09:30:51 2010 for ImpalaSrc by  doxygen 1.5.1