source: tags/before-XString-Modif/HepRep/src/DefaultHepRepInstance.cc

Last change on this file was 834, checked in by garnier, 16 years ago

import all except CVS

File size: 2.8 KB
Line 
1// Copyright FreeHEP, 2005.
2
3#include <iostream>
4
5#include "cheprep/DefaultHepRepInstance.h"
6
7using namespace std;
8using namespace HEPREP;
9
10/**
11 * @author Mark Donszelmann
12 * @version $Id: DefaultHepRepInstance.cc,v 1.7 2005/06/02 21:28:45 duns Exp $
13 */
14namespace cheprep {
15
16DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstance* instance, HepRepType* heprepType)
17    : DefaultHepRepAttribute(), parent(instance), type(heprepType) {
18
19    if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
20    parent->addInstance(this);
21}
22
23DefaultHepRepInstance::DefaultHepRepInstance(HepRepInstanceTree* instanceTree, HepRepType* heprepType)
24    : DefaultHepRepAttribute(), parent(NULL), type(heprepType) {
25
26    if (type == NULL) cerr << "HepRepInstance cannot be created without a HepRepType." << endl;
27    instanceTree->addInstance(this);
28}
29
30DefaultHepRepInstance::~DefaultHepRepInstance() {
31    parent = NULL;
32    type = NULL;
33    for (vector<HepRepInstance*>::iterator i1 = instances.begin(); i1 != instances.end(); i1++) {
34        delete (*i1);
35    }
36    for (vector<HepRepPoint*>::iterator i2 = points.begin(); i2 != points.end(); i2++) {
37        delete (*i2);
38    }
39}
40
41void DefaultHepRepInstance::overlay(HepRepInstance *) {
42    cerr << "DefaultHepRepInstance::overlay(HepRepInstance * instance) not implemented." << endl;
43}
44
45HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) {
46    cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstance*, HepRepSelectFilter*) not implemented." << endl;
47    return NULL;
48}
49
50HepRepInstance* DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) {
51    cerr << "DefaultHepRepInstance::copy(HepRepTypeTree*, HepRepInstanceTree*, HepRepSelectFilter*) not implemented." << endl;
52    return NULL;
53}
54
55HepRepType* DefaultHepRepInstance::getType() {
56    return type;
57}
58
59void DefaultHepRepInstance::addPoint(HepRepPoint* point) {
60    points.push_back(point);
61}
62
63vector<HepRepPoint*> DefaultHepRepInstance::getPoints() {
64    return points;
65}
66
67HepRepInstance* DefaultHepRepInstance::getSuperInstance() {
68    return parent;
69}
70
71void DefaultHepRepInstance::addInstance(HepRepInstance* instance) {
72    instances.push_back(instance);
73}
74
75void DefaultHepRepInstance::removeInstance(HepRepInstance*) {
76    cerr << "DefaultHepRepInstance::removeInstance(HepRepInstance*) not implemented." << endl;
77}
78
79vector<HepRepInstance*> DefaultHepRepInstance::getInstances() {
80    return instances;
81}
82
83HepRepAttValue* DefaultHepRepInstance::getAttValue(string name) {
84    HepRepAttValue* value = getAttValueFromNode(name);
85    return (value != NULL) ? value : type->getAttValue(name);
86}
87
88} // cheprep
Note: See TracBrowser for help on using the repository browser.