DEADSOFTWARE

Completely convert .odc to .txt using Visitor
[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 TypeProxy<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::getType() {
38 return Store::TYPENAME;
39 }
41 const std::string *Store::getSuper() {
42 return 0;
43 }
45 const std::string &Store::getTypeName() const {
46 return Store::getType();
47 }
49 void Store::getTypePath(TypePath *out) const {
50 return calcTypePath(out, getTypeName());
51 }
53 void Store::calcTypePath(TypePath *path, const std::string &name) const {
54 const std::string *super = TypeRegister::getInstance().get(name)->getSuper();
55 if (super != 0) {
56 calcTypePath(path, *super);
57 }
58 path->push_back(name);
59 }
61 void Store::internalize(Reader &reader) {
62 reader.readVersion(0, 0);
63 }
65 std::string Store::toString() {
66 return getTypeName();
67 }
69 void Store::accept(Visitor &visitor) const {}
71 const std::string Elem::TYPENAME("Stores.Elem^");
72 const TypeProxy<Elem> Elem::PROXY;
74 Elem::Elem(INTEGER id) : Store(id) {}
76 const std::string &Elem::getType() {
77 return TYPENAME;
78 }
80 const std::string *Elem::getSuper() {
81 return &Store::getType();
82 }
84 const std::string &Elem::getTypeName() const {
85 return getType();
86 }
88 void Elem::internalize(Reader &reader) {
89 Store::internalize(reader);
90 if (reader.isCancelled()) return;
91 reader.readVersion(0, 0);
92 }
94 const std::string Model::TYPENAME("Models.Model^");
95 const TypeProxy<Model> Model::PROXY;
97 Model::Model(INTEGER id) : Elem(id) {}
99 const std::string &Model::getType() {
100 return TYPENAME;
103 const std::string *Model::getSuper() {
104 return &Elem::getType();
107 const std::string &Model::getTypeName() const {
108 return getType();
111 void Model::internalize(Reader &reader) {
112 Elem::internalize(reader);
113 if (reader.isCancelled()) return;
114 reader.readVersion(0, 0);
117 const std::string ContainerModel::TYPENAME("Containers.Model^");
118 const TypeProxy<ContainerModel> ContainerModel::PROXY;
120 ContainerModel::ContainerModel(INTEGER id) : Model(id) {}
122 const std::string &ContainerModel::getType() {
123 return TYPENAME;
126 const std::string *ContainerModel::getSuper() {
127 return &Model::getType();
130 const std::string &ContainerModel::getTypeName() const {
131 return getType();
134 void ContainerModel::internalize(Reader &reader) {
135 Model::internalize(reader);
136 if (reader.isCancelled()) return;
137 reader.readVersion(0, 0);
140 } // namespace odc