DEADSOFTWARE

Almost-correct toPlainText
[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 std::string Store::toPlainText() {
69 return std::string();
70 }
72 const std::string Elem::TYPENAME("Stores.Elem^");
73 const TypeProxy<Elem> Elem::PROXY;
75 Elem::Elem(INTEGER id) : Store(id) {}
77 const std::string &Elem::getType() {
78 return TYPENAME;
79 }
81 const std::string *Elem::getSuper() {
82 return &Store::getType();
83 }
85 const std::string &Elem::getTypeName() const {
86 return getType();
87 }
89 void Elem::internalize(Reader &reader) {
90 Store::internalize(reader);
91 if (reader.isCancelled()) return;
92 reader.readVersion(0, 0);
93 }
95 const std::string Model::TYPENAME("Models.Model^");
96 const TypeProxy<Model> Model::PROXY;
98 Model::Model(INTEGER id) : Elem(id) {}
100 const std::string &Model::getType() {
101 return TYPENAME;
104 const std::string *Model::getSuper() {
105 return &Elem::getType();
108 const std::string &Model::getTypeName() const {
109 return getType();
112 void Model::internalize(Reader &reader) {
113 Elem::internalize(reader);
114 if (reader.isCancelled()) return;
115 reader.readVersion(0, 0);
118 const std::string ContainerModel::TYPENAME("Containers.Model^");
119 const TypeProxy<ContainerModel> ContainerModel::PROXY;
121 ContainerModel::ContainerModel(INTEGER id) : Model(id) {}
123 const std::string &ContainerModel::getType() {
124 return TYPENAME;
127 const std::string *ContainerModel::getSuper() {
128 return &Model::getType();
131 const std::string &ContainerModel::getTypeName() const {
132 return getType();
135 void ContainerModel::internalize(Reader &reader) {
136 Model::internalize(reader);
137 if (reader.isCancelled()) return;
138 reader.readVersion(0, 0);
141 } // namespace odc