DynamicParam.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/exec/DynamicParam.h#13 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2004-2009 SQLstream, Inc.
00006 // Copyright (C) 2004-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_DynamicParam_Included
00025 #define Fennel_DynamicParam_Included
00026 
00027 #include "fennel/common/SharedTypes.h"
00028 #include "fennel/tuple/TupleData.h"
00029 #include "fennel/tuple/TupleDescriptor.h"
00030 #include "fennel/synch/SynchObj.h"
00031 
00032 #include <map>
00033 #include <boost/scoped_array.hpp>
00034 
00035 
00036 FENNEL_BEGIN_NAMESPACE
00037 
00045 class FENNEL_EXEC_EXPORT DynamicParam
00046 {
00047     friend class DynamicParamManager;
00048 
00049     boost::scoped_array<FixedBuffer> pBuffer;
00050     TupleAttributeDescriptor desc;
00051     TupleDatum datum;
00052     bool isCounter;
00053 
00054 public:
00055     explicit DynamicParam(
00056         TupleAttributeDescriptor const &desc,
00057         bool isCounter = false);
00058     inline TupleDatum const &getDatum() const;
00059     inline TupleAttributeDescriptor const &getDesc() const;
00060 };
00061 
00067 class FENNEL_EXEC_EXPORT DynamicParamManager
00068 {
00069     typedef std::map<DynamicParamId, SharedDynamicParam> ParamMap;
00070     typedef ParamMap::const_iterator ParamMapConstIter;
00071 
00072     StrictMutex mutex;
00073 
00074     ParamMap paramMap;
00075 
00076     DynamicParam &getParamInternal(DynamicParamId dynamicParamId);
00077 
00078     void createParam(
00079         DynamicParamId dynamicParamId,
00080         SharedDynamicParam param,
00081         bool failIfExists);
00082 public:
00095     void createParam(
00096         DynamicParamId dynamicParamId,
00097         const TupleAttributeDescriptor &attrDesc,
00098         bool failIfExists = true);
00099 
00111     void createCounterParam(
00112         DynamicParamId dynamicParamId,
00113         bool failIfExists = true);
00114 
00120     void deleteParam(DynamicParamId dynamicParamId);
00121 
00130     void writeParam(DynamicParamId dynamicParamId, const TupleDatum &src);
00131 
00139     DynamicParam const &getParam(DynamicParamId dynamicParamId);
00140 
00149     void readParam(DynamicParamId dynamicParamId, TupleDatum &dest);
00150 
00156     void incrementCounterParam(DynamicParamId dynamicParamId);
00157 
00163     void decrementCounterParam(DynamicParamId dynamicParamId);
00164 
00168     void deleteAllParams();
00169 };
00170 
00171 inline TupleDatum const &DynamicParam::getDatum() const
00172 {
00173     return datum;
00174 }
00175 
00176 inline TupleAttributeDescriptor const &DynamicParam::getDesc() const
00177 {
00178     return desc;
00179 }
00180 
00181 FENNEL_END_NAMESPACE
00182 
00183 #endif
00184 
00185 // End DynamicParam.h

Generated on Mon Jun 22 04:00:18 2009 for Fennel by  doxygen 1.5.1