DEADSOFTWARE

Testing odcread against a bunch of existing .odc files
[odcread.git] / store.cc
1 #include <store.h>
2 #include <reader.h>
3 #include <visitor.h>
5 #include <iostream>
8 namespace odc {
10 template<class T, class A> T join(const A & begin, const A & end, const T &sep) {
11 T result;
13 if (begin != end) {
14 A it = begin;
15 result.append(*it);
16 for (++it; it != end; ++it) {
17 result.append(sep).append(*it);
18 }
19 }
21 return result;
22 }
24 std::string TypePath::toString() const {
25 return join(begin(), end(), std::string("->"));
26 }
28 const std::string Store::TYPENAME("Stores.Store^");
29 const TopTypeProxy<Store> Store::PROXY;
31 Store::Store(INTEGER id): d_id(id) {}
33 INTEGER Store::getId() {
34 return d_id;
35 }
37 const std::string &Store::getTypeName() const {
38 return Store::TYPENAME;
39 }
41 TypePath Store::getTypePath() const {
42 TypePath out;
43 calcTypePath(&out, getTypeName());
44 return out;
45 }
47 void Store::calcTypePath(TypePath *path, const std::string &name) const {
48 const std::string *super = TypeRegister::getInstance().get(name)->getSuper();
49 if (super != 0) {
50 calcTypePath(path, *super);
51 }
52 path->push_back(name);
53 }
55 void Store::internalize(Reader &reader) {
56 reader.readVersion(0, 0);
57 }
59 std::string Store::toString() {
60 return getTypeName();
61 }
63 void Store::accept(Visitor &visitor) const {}
65 const std::string Elem::TYPENAME("Stores.Elem^");
66 const TypeProxy<Elem, Store> Elem::PROXY;
68 Elem::Elem(INTEGER id) : Store(id) {}
70 const std::string &Elem::getTypeName() const {
71 return TYPENAME;
72 }
74 void Elem::internalize(Reader &reader) {
75 Store::internalize(reader);
76 if (reader.isCancelled()) return;
77 reader.readVersion(0, 0);
78 }
80 const std::string Model::TYPENAME("Models.Model^");
81 const TypeProxy<Model, Elem> Model::PROXY;
83 Model::Model(INTEGER id) : Elem(id) {}
85 const std::string &Model::getTypeName() const {
86 return TYPENAME;
87 }
89 void Model::internalize(Reader &reader) {
90 Elem::internalize(reader);
91 if (reader.isCancelled()) return;
92 reader.readVersion(0, 0);
93 }
95 const std::string ContainerModel::TYPENAME("Containers.Model^");
96 const TypeProxy<ContainerModel, Model> ContainerModel::PROXY;
98 ContainerModel::ContainerModel(INTEGER id) : Model(id) {}
100 const std::string &ContainerModel::getTypeName() const {
101 return TYPENAME;
104 void ContainerModel::internalize(Reader &reader) {
105 Model::internalize(reader);
106 if (reader.isCancelled()) return;
107 reader.readVersion(0, 0);
110 } // namespace odc