76 #include "StDbNode.hh"
77 #include "StDbDefaults.hh"
78 #include "stdb_streams.h"
87 StDbNode::StDbNode(
const char* name,
const char* versionKey): mname(0), mversion(0), mdbName(0), mnodeID(0),mnodeType(0){
90 setVersion(versionKey);
91 misConfigured =
false;
96 StDbNode::StDbNode(
const char* name ): mname(0), mversion(0), mdbName(0), mnodeID(0) ,mnodeType(0){
98 setVersion(StDbDefaults::Instance()->printVersion());
99 misConfigured =
false;
100 mcanRollBack =
false;
106 mname = node.getName();
107 mversion = node.getVersion();
108 mdbName = node.getDbName();
109 mdbType = node.getDbType();
110 mdbDomain = node.getDbDomain();
111 mnodeID = node.getNodeID();
112 mnodeType = node.getNodeType();
113 misConfigured = node.IsConfigured();
114 mcanRollBack = node.canRollBack();
118 StDbNode::~StDbNode(){
119 if(mname)
delete [] mname;
120 if(mversion)
delete [] mversion;
121 if(mdbName)
delete [] mdbName;
122 if(mnodeType)
delete [] mnodeType;
127 char* StDbNode::getName() {
return mstrDup((
const char*)mname); };
128 char* StDbNode::getVersion() {
return mstrDup((
const char*)mversion); }
129 char* StDbNode::getDbName() {
return mstrDup((
const char*)mdbName); }
130 char* StDbNode::getNodeType() {
return mstrDup(mnodeType); }
132 void StDbNode::setName(
const char* nodeName) {
133 if(mname)
delete [] mname;
134 mname=mstrDup(nodeName);
136 void StDbNode::setVersion(
const char* version){
137 if(mversion)
delete [] mversion;
138 mversion=mstrDup(version);
140 void StDbNode::setDbName(
const char* dbName) {
141 if(mdbName)
delete [] mdbName;
142 mdbName=mstrDup(dbName);
144 void StDbNode::setNodeType(
const char* type) {
145 if(mnodeType)
delete [] mnodeType;
146 mnodeType=mstrDup(type);
150 int* StDbNode::decodeElementID(
const char* elemID,
int& numRows) {
154 char*
id=strstr((
char*)elemID,
"None");
158 int* e =
new int[1]; *e=0;
162 char* tmpName =
new char[strlen(elemID)+1];
163 strcpy(tmpName,elemID);
166 id = strstr(tmpName,
",");
170 id2 = strstr(tmpName,
"-");
173 if(id2 && ( (
id && id2<
id) || !
id)){
189 if(
id && id2 && id2<
id){
198 char* islist=
new char[strlen((sl.str()).c_str())+1];
199 strcpy(islist,(sl.str()).c_str());
203 int* tmpElements =
new int[100000];
204 char* p1=&tmpName[0];
206 anID = getNextID(p1);
208 tmpElements[0] = atoi(anID);
213 for(
int ient=1;ient<numEntries;ient++){
214 anID = getNextID(p1);
216 if(islist[ient-1]==
'r'){
218 iStart = tmpElements[numElements-1];
219 int irange=iEnd-iStart;
220 for(
int ir=1;ir<=irange;ir++){
222 tmpElements[numElements-1]=iStart+ir;
226 tmpElements[numElements-1]=atoi(anID);
232 retVal =
new int[numElements];
233 for(k=0;k<numElements;k++)retVal[k]=tmpElements[k];
234 numRows = numElements;
237 delete [] tmpElements;
245 StDbNode::getNextID(
char*& currentElement)
const {
248 if(!currentElement)
return nextID;
250 char*
id = strstr(currentElement,
",");
253 nextID =
new char[strlen(currentElement)+1];
254 strcpy(nextID,currentElement);
257 int iloc =
id-currentElement;
258 nextID =
new char[iloc+1];
259 strncpy(nextID,currentElement,iloc);
261 currentElement = id; currentElement++;
268 char* StDbNode::mstrDup(
const char* s2) {
272 s1 =
new char[strlen(s2)+1];