Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

StDbStoreInfo.cc

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * 00003 * $Id: StDbStoreInfo.cc,v 1.1 2001/01/22 18:38:00 porter Exp $ 00004 * 00005 * Author: R. Jeff Porter 00006 *************************************************************************** 00007 * 00008 * Description: Simple integer array implementation of the database 00009 * dataID fields. These are held during writes so that a 00010 * many-row table or a multi-table write can be rolled back 00011 * completely on failure at some point in the writing 00012 * 00013 *************************************************************************** 00014 * 00015 * $Log: StDbStoreInfo.cc,v $ 00016 * Revision 1.1 2001/01/22 18:38:00 porter 00017 * Update of code needed in next year running. This update has little 00018 * effect on the interface (only 1 method has been changed in the interface). 00019 * Code also preserves backwards compatibility so that old versions of 00020 * StDbLib can read new table structures. 00021 * -Important features: 00022 * a. more efficient low-level table structure (see StDbSql.cc) 00023 * b. more flexible indexing for new systems (see StDbElememtIndex.cc) 00024 * c. environment variable override KEYS for each database 00025 * d. StMessage support & clock-time logging diagnostics 00026 * -Cosmetic features 00027 * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access 00028 * f. removed codes that have been obsolete for awhile (e.g. db factories) 00029 * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI 00030 * and mysqlAccessor became StDbSql) 00031 * 00032 **************************************************************************/ 00033 #include "StDbStoreInfo.hh" 00034 #include <string.h> 00035 00036 #define N_ROWS_INCREMENT 500 00037 00038 StDbStoreInfo::StDbStoreInfo() : mdataIDs(0), mnumRows(0), mMaxRows(0), mcanRollBack(false) {}; 00039 00040 StDbStoreInfo::~StDbStoreInfo() { resetStoreInfo(); } 00041 00043 00044 void StDbStoreInfo::reSizeInternalStore(){ 00045 00046 int newMaxRows = mMaxRows+N_ROWS_INCREMENT; 00047 int* newDataIDs = new int[newMaxRows]; 00048 00049 memset(newDataIDs,0,newMaxRows*sizeof(int)); 00050 if(mdataIDs){ 00051 memcpy(newDataIDs,mdataIDs,mnumRows*sizeof(int)); 00052 delete [] mdataIDs; 00053 } 00054 mdataIDs = newDataIDs; 00055 mMaxRows = newMaxRows; 00056 00057 } 00058 00060 00061 int* StDbStoreInfo::getDataIDs(int& numRows){ 00062 numRows=mnumRows; 00063 return mdataIDs; 00064 } 00065 00067 00068 void StDbStoreInfo::addWrittenRow(int dataID){ 00069 00070 if(mnumRows==mMaxRows)reSizeInternalStore(); 00071 mdataIDs[mnumRows]=dataID; 00072 mnumRows++; 00073 00074 }; 00075 00076 00077 void StDbStoreInfo::resetStoreInfo(){ 00078 if(mdataIDs) delete [] mdataIDs; 00079 mdataIDs=0; 00080 mnumRows=0; 00081 mMaxRows=0; 00082 mcanRollBack=false; 00083 } 00084

Generated on Thu Aug 24 14:45:27 2006 for Doxygen by doxygen 1.3.7