UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
descriptionprotocol.h
Go to the documentation of this file.
1 
2 
3 #ifndef UGDK_UTIL_DESCRIPTIONPROTOCOL_H_
4 #define UGDK_UTIL_DESCRIPTIONPROTOCOL_H_
5 
6 #include <string>
7 #include <vector>
9 #include <cstdio>
10 
11 namespace ugdk {
12 
13 namespace gdd {
14 
15 typedef std::string GDDString;
16 typedef std::vector<GDDString> GDDArgs;
17 
18 class LoadError {
19  public:
20  enum Type {
23  };
24 };
25 
26 template <class T>
28 
29  public:
30 
31  virtual ~DescriptionProtocol() {}
32 
33  void set_loader(AbstractLoader<T> *loader) { loader_ = loader; }
34 
35  AbstractLoader<T>* loader() const { return loader_; }
36 
37  virtual bool NewDescription() = 0;
38 
39  virtual bool NewData(const GDDString& data_name) = 0;
40 
41  virtual bool NewProperty(const GDDString& property_name,
42  const GDDArgs& property_args) = 0;
43 
44  virtual bool NewRing(const GDDString& ring_typename) = 0;
45 
46  virtual bool NewEntry(const GDDString& entry_name, const GDDArgs& entry_args) = 0;
47 
48  virtual bool NewSimpleChain(const GDDString& ring_typename,
49  const GDDArgs& ring_args) = 0;
50 
51  protected:
52 
53  DescriptionProtocol() : loader_(NULL) {}
54 
55  void error(LoadError::Type error_type, std::string &msg = "") {
56  switch (error_type) {
58  fprintf(stderr, "Load Error: type mismatch. %s\n", msg.c_str());
59  break;
61  fprintf(stderr, "Load Error: invalid value. %s\n", msg.c_str());
62  break;
63  default:
64  fprintf(stderr, "Load Error: unknown. %s\n", msg.c_str()); // \comofas
65  break;
66  }
67  }
68 
69  private:
70 
71  AbstractLoader<T> *loader_;
72 
73 };
74 
75 } /* namespace gdd */
76 
77 } /* namespace ugdk */
78 
79 #endif /* UGDK_UTIL_DESCRIPTIONPROTOCOL_H_ */