00001
00002
00003 #include <iostream>
00004
00005 #include "cheprep/DefaultHepRepInstance.h"
00006
00007 using namespace std;
00008 using namespace HEPREP;
00009
00014 namespace cheprep {
00015
00016 DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstance* instance, HepRepType* heprepType)
00017 : DefaultHepRepAttribute(), parent(instance), type(heprepType) {
00018
00019 if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
00020 parent->addInstance(this);
00021 }
00022
00023 DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstanceTree* instanceTree, HepRepType* heprepType)
00024 : DefaultHepRepAttribute(), parent(NULL), type(heprepType) {
00025
00026 if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
00027 instanceTree->addInstance(this);
00028 }
00029
00030 DefaultHepRepInstance::~DefaultHepRepInstance() {
00031 parent = NULL;
00032 type = NULL;
00033 for (vector<HepRepInstance*>::iterator i1 = instances.begin(); i1 != instances.end(); i1++) {
00034 delete (*i1);
00035 }
00036 for (vector<HepRepPoint*>::iterator i2 = points.begin(); i2 != points.end(); i2++) {
00037 delete (*i2);
00038 }
00039 }
00040
00041 void DefaultHepRepInstance::overlay(HepRepInstance *) {
00042 cerr << "DefaultHepRepInstance::overlay(HepRepInstance * instance) not implemented." << endl;
00043 }
00044
00045 HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) {
00046 cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) not implemented." << endl;
00047 return NULL;
00048 }
00049
00050 HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) {
00051 cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) not implemented." << endl;
00052 return NULL;
00053 }
00054
00055 HepRepType* DefaultHepRepInstance::getType() {
00056 return type;
00057 }
00058
00059 void DefaultHepRepInstance::addPoint(HepRepPoint* point) {
00060 points.push_back(point);
00061 }
00062
00063 vector<HepRepPoint*> DefaultHepRepInstance::getPoints() {
00064 return points;
00065 }
00066
00067 HepRepInstance* DefaultHepRepInstance::getSuperInstance() {
00068 return parent;
00069 }
00070
00071 void DefaultHepRepInstance::addInstance(HepRepInstance* instance) {
00072 instances.push_back(instance);
00073 }
00074
00075 void DefaultHepRepInstance::removeInstance(HepRepInstance*) {
00076 cerr << "DefaultHepRepInstance::removeInstance(HepRepInstance*) not implemented." << endl;
00077 }
00078
00079 vector<HepRepInstance*> DefaultHepRepInstance::getInstances() {
00080 return instances;
00081 }
00082
00083 HepRepAttValue* DefaultHepRepInstance::getAttValue(string name) {
00084 HepRepAttValue* value = getAttValueFromNode(name);
00085 return (value != NULL) ? value : type->getAttValue(name);
00086 }
00087
00088 }