00001 /* 00002 // $Id: //open/dev/fennel/tuple/TupleData.h#24 $ 00003 // Fennel is a library of data storage and processing components. 00004 // Copyright (C) 2005-2009 The Eigenbase Project 00005 // Copyright (C) 2003-2009 SQLstream, Inc. 00006 // Copyright (C) 2005-2009 LucidEra, Inc. 00007 // Portions Copyright (C) 1999-2009 John V. Sichi 00008 // 00009 // This program is free software; you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by the Free 00011 // Software Foundation; either version 2 of the License, or (at your option) 00012 // any later version approved by The Eigenbase Project. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with this program; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 */ 00023 00024 #ifndef Fennel_TupleData_Included 00025 #define Fennel_TupleData_Included 00026 00027 #include "fennel/tuple/StandardTypeDescriptor.h" 00028 #include "fennel/tuple/TupleDescriptor.h" 00029 00030 #include <vector> 00031 00032 00033 FENNEL_BEGIN_NAMESPACE 00034 00035 00036 class TupleDescriptor; 00037 class TupleProjection; 00038 00044 struct FENNEL_TUPLE_EXPORT TupleDatum 00045 { 00046 TupleStorageByteLength cbData; 00047 PConstBuffer pData; 00048 00049 union 00050 { 00051 uint16_t data16; 00052 uint32_t data32; 00053 uint64_t data64; 00054 }; 00055 00056 inline explicit TupleDatum(); 00057 inline TupleDatum(TupleDatum const &other); 00058 00059 /* 00060 * Test if this TupleDatum represents NULL value. 00061 * 00062 * @return true if this TupleDatum represents NULL. 00063 */ 00064 inline bool isNull() const; 00065 00069 inline void setNull(); 00070 00079 inline TupleDatum &operator = (TupleDatum const &other); 00080 00091 inline void copyFrom(TupleDatum const &other); 00092 00111 void memCopyFrom(TupleDatum const &other); 00112 }; 00113 00118 class FENNEL_TUPLE_EXPORT TupleData 00119 : public std::vector<TupleDatum> 00120 { 00121 public: 00122 inline explicit TupleData(); 00123 inline explicit TupleData(TupleDescriptor const &tupleDesc); 00124 00125 void compute(TupleDescriptor const &); 00126 00127 bool containsNull() const; 00128 00129 bool containsNull(TupleProjection const &tupleProj) const; 00130 00132 void projectFrom(TupleData const& src, TupleProjection const&); 00133 }; 00134 00135 /**************************************************** 00136 Definitions of inline methods for class TupleDatum 00137 ****************************************************/ 00138 00139 inline TupleDatum::TupleDatum() 00140 { 00141 cbData = 0; 00142 pData = NULL; 00143 } 00144 00145 inline TupleDatum::TupleDatum(TupleDatum const &other) 00146 { 00147 copyFrom(other); 00148 } 00149 00150 inline bool TupleDatum::isNull() const 00151 { 00152 return (!pData); 00153 } 00154 00155 inline void TupleDatum::setNull() 00156 { 00157 pData = NULL; 00158 } 00159 00160 inline TupleDatum &TupleDatum::operator = (TupleDatum const &other) 00161 { 00162 copyFrom(other); 00163 return *this; 00164 } 00165 00166 inline void TupleDatum::copyFrom(TupleDatum const &other) 00167 { 00168 cbData = other.cbData; 00169 pData = other.pData; 00170 } 00171 00172 /*************************************************** 00173 Definitions of inline methods for class TupleData 00174 ***************************************************/ 00175 00176 inline TupleData::TupleData() 00177 { 00178 } 00179 00180 inline TupleData::TupleData(TupleDescriptor const &tupleDesc) 00181 { 00182 compute(tupleDesc); 00183 } 00184 00185 FENNEL_END_NAMESPACE 00186 00187 #endif 00188 00189 // End TupleData.h