133 #include "stdb_streams.h"
136 #include "StDbConfigNode.hh"
137 #include "StDbManager.hh"
138 #include "StDbTable.h"
144 #define __CLASS__ "StDbConfigNode"
148 StDbConfigNode::StDbConfigNode(
StDbConfigNode* parent,
const char* nodeName,
const char* configName):
StDbNode(nodeName,configName) {
151 setParentNode(parent);
152 setDbName(parent->printDbName());
153 setDbType(parent->getDbType());
154 setDbDomain(parent->getDbDomain());
160 setParentNode(parent);
164 StDbConfigNode::StDbConfigNode(StDbType type, StDbDomain domain,
const char* nodeName,
const char* configName):
StDbNode(nodeName,configName) {
172 StDbConfigNode::~StDbConfigNode(){ deleteChildren();};
175 void StDbConfigNode::zeroNodes() {
187 StDbConfigNode::setFlavor(
const char* flavor){
189 setTablesFlavor(flavor);
190 if(mfirstChildNode)mfirstChildNode->setFlavor(flavor);
191 if(mnextNode)mnextNode->setFlavor(flavor);
197 StDbConfigNode::setProdTime(
unsigned int ptime){
198 setTablesProdTime(ptime);
199 if(mfirstChildNode)mfirstChildNode->setProdTime(ptime);
200 if(mnextNode)mnextNode->setProdTime(ptime);
205 StDbConfigNode::setProdTimeOverride(
unsigned int ptime,
char*
dbType,
char*
dbDomain) {
206 bool isAllTypesAccepted =
false;
209 std::string completeName;
210 if (dbType && dbType[0] !=
'\0' && dbType[0] !=
' ' && dbType[0] !=
'*') {
211 completeName.append(dbType);
213 isAllTypesAccepted =
true;
215 completeName.append(
"_");
216 if (dbDomain && dbDomain[0] !=
'\0' && dbDomain[0] !=
' ' && dbDomain[0] !=
'*') {
217 completeName.append(dbDomain);
221 std::string currentName;
222 if ( this->getDbDomain() <= dbDUser1 ) {
223 if (!isAllTypesAccepted) {
228 currentName.append(
"_");
234 if (completeName == currentName) {
236 setTablesProdTimeOverride(ptime, dbType, dbDomain);
239 if (mfirstChildNode) {
241 mfirstChildNode->setProdTimeOverride(ptime, dbType, dbDomain);
246 mnextNode->setProdTimeOverride(ptime, dbType, dbDomain);
253 StDbConfigNode::deleteTree(){
255 if(mfirstChildNode)
delete mfirstChildNode;
257 mnextNode->deleteTree();
264 StDbConfigNode::deleteChildren(){
278 StDbConfigNode::findConfigNode(StDbType type, StDbDomain domain,
const char* subPath){
280 return node->findConfigNode(subPath);
286 StDbConfigNode::findConfigNode(StDbType type, StDbDomain domain){
297 if(isNode(type,domain)){
298 if(mparentNode && mparentNode->isNode(type,domain))
299 return mparentNode->findConfigNode(type,domain);
304 if(hasChildren())node=mfirstChildNode->findConfigNode(type,domain);
305 if(!node && mnextNode)node = mnextNode->findConfigNode(type,domain);
313 StDbConfigNode::findConfigNode(
const char* subPath){
321 if(!subPath)
return node;
322 char* path = mstrDup(subPath);
324 if(path[0]==
'/')path++;
325 char*
id=strstr(path,
"/");
326 if(
id){ *
id=
'\0';
id++; }
327 char* nextNodeName=mstrDup(path);
328 node=getFirstChildNode();
333 if(!node->checkName(nextNodeName)){
334 node=node->getNextNode();
335 if(!node) found=
true;
344 node=node->findConfigNode(
id);
349 delete [] nextNodeName;
356 StDbConfigNode::findChildConfigNode(
const char* name){
359 if(!name)
return retVal;
360 retVal=getFirstChildNode();
362 if(retVal->checkName(name))
break;
363 retVal=retVal->getNextNode();
370 mparentNode = parent;
371 parent->setChildNode(
this);
377 mnextNode->appendNode(node);
386 if(mfirstChildNode) {
387 mfirstChildNode->appendNode(node);
389 mfirstChildNode = node;
396 if(mfirstChildNode)node->appendNode(mfirstChildNode);
405 StDbConfigNode::printTree(
int depth){
407 if(!depth)cout<<endl<<
"************* Node Structure ****************" <<endl<<endl;
410 for(
int k=0;k<depth;k++)cout<<
" ";
411 cout<<
"Node=" << mname <<
" VersionKey = " << mversion <<endl;
413 int depth2 = depth+4;
418 if(mfirstChildNode)mfirstChildNode->printTree(depth3);
419 if(mnextNode)mnextNode->printTree(depth);
421 if(!depth)cout<<endl<<
"*********************************************" << endl;
static StDbManager * Instance()
strdup(..) is not ANSI