Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DefaultHepRepType.cc
Go to the documentation of this file.
1 // Copyright FreeHEP, 2005.
2 
4 
5 using namespace std;
6 using namespace HEPREP;
7 
8 /**
9  * @author Mark Donszelmann
10  * @version $Id: DefaultHepRepType.cc 66373 2012-12-18 09:41:34Z gcosmo $
11  */
12 namespace cheprep {
13 
14 DefaultHepRepType::DefaultHepRepType(HepRepType* parentType, string typeName)
15  : DefaultHepRepDefinition(), parent(parentType), name(typeName) {
16  this->description = "No Description";
17  this->infoURL = "No Info URL";
18 
19  // HepRepTypes are sometimes used without a parent (top-level)
20  if (parent != NULL) {
21  parent->addType(this);
22  }
23 }
24 
25 DefaultHepRepType::DefaultHepRepType(HepRepTypeTree* parentTypeTree, string typeName)
26  : DefaultHepRepDefinition(), parent(NULL), name(typeName) {
27  this->description = "No Description";
28  this->infoURL = "No Info URL";
29 
30  parentTypeTree->addType(this);
31 }
32 
34  for (vector<HepRepType*>::iterator i1 = types.begin(); i1 != types.end(); i1++) {
35  delete (*i1);
36  }
37 }
38 
40  return parent;
41 }
42 
44  HepRepAttDef* def = NULL;
45  HepRepType* type = this;
46  while ((def == NULL) && (type != NULL)) {
47  def = type->getAttDefFromNode(defName);
48  type = type->getSuperType();
49  }
50  if (def == NULL) {
51  cerr << "ERROR: No HepRepDefaults, trying to get definition for: " << defName << endl;
52  // FIXME, no HepRepDefaults
53  }
54  return def;
55 }
56 
57 /**
58  * searched for a value with given name. Search up the type tree if needed.
59  */
61  HepRepAttValue* value = NULL;
62  HepRepType* type = this;
63  while ((value == NULL) && (type != NULL)) {
64  value = type->getAttValueFromNode(attName);
65  type = type->getSuperType();
66  }
67  if (value == NULL) {
68  cerr << "ERROR: No HepRepDefaults, trying to get value for: " << attName << endl;
69  // FIXME, no HepRepDefaults
70  }
71  return value;
72 }
73 
75  cerr << "DefaultHepRepType::copy(HepRepType*) not implemented." << endl;
76  return NULL;
77 }
78 
80  return name;
81 }
82 
84  return (getSuperType() == NULL) ? getName() : getSuperType()->getFullName() + "/" + getName();
85 }
86 
88  return description;
89 }
90 
92  this->description = desc;
93 }
94 
96  return infoURL;
97 }
98 
100  this->infoURL = info;
101 }
102 
104  // FIXME should check if type already exists
105  types.push_back(type);
106 }
107 
108 vector<HepRepType*> DefaultHepRepType::getTypeList() {
109  return types;
110 }
111 
112 
113 } // cheprep
virtual void addType(HepRepType *type)=0
const XML_Char * name
HEPREP::HepRepAttDef * getAttDef(std::string name)
virtual HepRepAttDef * getAttDefFromNode(std::string lowerCaseName)=0
virtual HepRepAttValue * getAttValueFromNode(std::string lowerCaseName)=0
virtual void addType(HepRepType *type)=0
HEPREP::HepRepAttValue * getAttValue(std::string name)
void setDescription(std::string description)
void addType(HEPREP::HepRepType *type)
void setInfoURL(std::string infoURL)
std::vector< HEPREP::HepRepType * > getTypeList()
const XML_Char XML_Encoding * info
const XML_Char int const XML_Char * value
virtual std::string getFullName()=0
DefaultHepRepType(HEPREP::HepRepType *parent, std::string name)
HEPREP::HepRepType * copy(HEPREP::HepRepType *parent)
virtual HepRepType * getSuperType()=0
HEPREP::HepRepType * getSuperType()