DEADSOFTWARE

Read NIL stores correctly
[odcread.git] / store.cc
1 #include <store.h>
2 #include <reader.h>
4 #include <iostream>
7 namespace odc {
9 template<class T, class A> T join(const A & begin, const A & end, const T &sep) {
10 T result;
12 if (begin != end) {
13 A it = begin;
14 result.append(*it);
15 for (++it; it != end; ++it) {
16 result.append(sep).append(*it);
17 }
18 }
20 return result;
21 }
23 std::string TypePath::toString() const {
24 return join(begin(), end(), std::string("->"));
25 }
27 const std::string Store::TYPENAME("Stores.Store^");
28 const TypeProxy<Store> Store::PROXY;
30 Store::Store(INTEGER id): d_id(id) {}
32 INTEGER Store::getId() {
33 return d_id;
34 }
36 const std::string &Store::getType() {
37 return Store::TYPENAME;
38 }
40 const std::string *Store::getSuper() {
41 return 0;
42 }
44 const std::string &Store::getTypeName() const {
45 return Store::getType();
46 }
48 void Store::getTypePath(TypePath *out) const {
49 return calcTypePath(out, getTypeName());
50 }
52 void Store::calcTypePath(TypePath *path, const std::string &name) const {
53 const std::string *super = TypeRegister::getInstance().get(name)->getSuper();
54 if (super != 0) {
55 calcTypePath(path, *super);
56 }
57 path->push_back(name);
58 }
60 void Store::internalize(Reader &reader) {
61 reader.readVersion(0, 0);
62 }
64 std::string Store::toString() {
65 return getTypeName();
66 }
68 const std::string Elem::TYPENAME("Stores.Elem^");
69 const TypeProxy<Elem> Elem::PROXY;
71 Elem::Elem(INTEGER id) : Store(id) {}
73 const std::string &Elem::getType() {
74 return TYPENAME;
75 }
77 const std::string *Elem::getSuper() {
78 return &Store::getType();
79 }
81 const std::string &Elem::getTypeName() const {
82 return getType();
83 }
85 void Elem::internalize(Reader &reader) {
86 Store::internalize(reader);
87 if (reader.isCancelled()) return;
88 reader.readVersion(0, 0);
89 }
91 const std::string Model::TYPENAME("Models.Model^");
92 const TypeProxy<Model> Model::PROXY;
94 Model::Model(INTEGER id) : Elem(id) {}
96 const std::string &Model::getType() {
97 return TYPENAME;
98 }
100 const std::string *Model::getSuper() {
101 return &Elem::getType();
104 const std::string &Model::getTypeName() const {
105 return getType();
108 void Model::internalize(Reader &reader) {
109 Elem::internalize(reader);
110 if (reader.isCancelled()) return;
111 reader.readVersion(0, 0);
114 const std::string ContainerModel::TYPENAME("Containers.Model^");
115 const TypeProxy<ContainerModel> ContainerModel::PROXY;
117 ContainerModel::ContainerModel(INTEGER id) : Model(id) {}
119 const std::string &ContainerModel::getType() {
120 return TYPENAME;
123 const std::string *ContainerModel::getSuper() {
124 return &Model::getType();
127 const std::string &ContainerModel::getTypeName() const {
128 return getType();
131 void ContainerModel::internalize(Reader &reader) {
132 Model::internalize(reader);
133 if (reader.isCancelled()) return;
134 reader.readVersion(0, 0);
137 } // namespace odc