ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
generate_baby.hpp
Go to the documentation of this file.
1 #ifndef H_GENERATE_BABY
2 #define H_GENERATE_BABY
3 
4 #include <string>
5 #include <map>
6 #include <set>
7 
9  SimpleVariable(const std::string &type, const std::string &name);
10  std::string type_;
11  std::string name_;
12 };
13 
14 class Variable{
15 public:
16  Variable(const std::string &name);
17 
18  const std::string & Name() const;
19  std::string & Name();
20 
21  std::string Type() const;
22  std::string Type(const std::string &baby_type) const;
23  std::string DecoratedType() const;
24  std::string DecoratedType(const std::string &baby_type) const;
25 
26  bool HasEntry(const std::string &baby_type) const;
27  void SetEntry(const std::string &baby_type,
28  const std::string &type);
29 
30  bool ImplementInBase() const;
31  bool VirtualInBase() const;
32  bool ImplementIn(const std::string &baby_type) const;
33  bool NotInBase() const;
34  bool EverythingIn(const std::string &baby_type) const;
35 
36  bool operator<(const Variable& other) const;
37 
38 private:
39  std::set<std::string> GetTypeSet() const;
40 
41  std::string name_;
42  std::map<std::string, std::string> type_map_;
43 };
44 
45 std::set<Variable> GetVariables(const std::set<std::string> &files);
46 
47 bool IsComment(const std::string &line);
48 
49 SimpleVariable GetVariable(std::string line);
50 
51 void RemoveExtraSpaces(std::string &line);
52 
53 void WriteBaseHeader(const std::set<Variable> &vars,
54  const std::set<std::string> &types);
55 
56 void WriteBaseSource(const std::set<Variable> &vars);
57 
58 void WriteSpecializedHeader(const std::set<Variable> &vars,
59  const std::string &type);
60 
61 void WriteSpecializedSource(const std::set<Variable> &vars,
62  const std::string &type);
63 
64 void WriteMergedHeader(const std::set<Variable> &vars,
65  const std::set<std::string> &types);
66 
67 #endif
void RemoveExtraSpaces(std::string &line)
Removes leading, trailing, and double spaced from a text line.
SimpleVariable(const std::string &type, const std::string &name)
Standard constructor.
std::string type_
Type of variable (e.g., int, float, etc.)
void WriteSpecializedHeader(const std::set< Variable > &vars, const std::string &type)
Writes a derived Baby header file.
bool IsComment(const std::string &line)
Check if line in variable list file is a comment (blank)
NamedFunc operator<(NamedFunc f, NamedFunc g)
Gets NamedFunc which tests if result of f is less than result of g.
Definition: named_func.cpp:720
void WriteBaseSource(const std::set< Variable > &vars)
Writes src/baby.cpp.
std::set< Variable > GetVariables(const std::set< std::string > &files)
SimpleVariable GetVariable(std::string line)
Extracts variable type and name from line from variable text files.
void WriteMergedHeader(const std::set< Variable > &vars, const std::set< std::string > &types)
Pairs a type and name of a variable accessible via Baby.
std::map< std::string, std::string > type_map_
Map from Baby type (basic, full, etc.) to variabl type (int, float, etc.)
void WriteBaseHeader(const std::set< Variable > &vars, const std::set< std::string > &types)
Writes inc/baby.hpp.
std::string name_
Name of variable (e.g., ht, met, etc.)
void WriteSpecializedSource(const std::set< Variable > &vars, const std::string &type)
Writes a derived Baby source file.
std::string name_
Name of variable (e.g., ht, met, etc.)
A variable to be accessible in Baby classes.