VR-Forces 4.1.1 Class Documentation
attributeConfigParser.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #include <iosfwd>
12 #include <features/feature.h>
13 #include <features/query.h>
15 
16 #include <vlutil/vlExceptions.h>
17 
18 #include <boost/ptr_container/ptr_map.hpp>
19 #include <tbb/recursive_mutex.h>
20 
21 namespace MAKVRinTerra
22 {
23  class DtAttributeConfigParser;
24 
26  {
28  {
31  DoubleAttr
32  };
33 
34  static AttributeType stringToType(const std::string& str);
35 
36  boost::optional<DtFeature::Attribute> evaluate(const DtFeature& feature) const;
37 
38  void print(std::ostream&) const;
39 
40  std::string myQueryName;
43  std::string myExpression;
44  };
45 
46  std::ostream& operator<<(std::ostream&, const DtFeatureTransform&);
47 
52  {
53  public:
54  typedef std::map<std::string, DtQuery> DtQueryMap;
55  typedef std::vector<DtFeatureTransform> TransformVector;
56 
58  virtual ~DtAttributeConfigParser();
59 
63  virtual bool readAttributeConfig(const std::string& filename, const DtQuery& schema= DtQuery());
64 
66  virtual DtQueryMap queryMap() const;
67 
69  virtual DtQuery findQuery(std::string) const;
70 
72  virtual TransformVector transforms() const;
73 
74  virtual void print(std::ostream&) const;
75 
76  virtual std::string pprintQueries() const;
77  virtual std::string pprintTransforms() const;
78 
88  virtual void resolveNamedQueries();
89 
92  {
93  public:
94  DtParseException(const char *errorMessage,
95  const DtException *previousException = 0) throw()
96  : DtException(errorMessage, previousException) {};
97 
98  virtual ~DtParseException() throw() {};
99  };
100 
102  {
103  public:
104  DtNamedQueryException(std::string missingQueryName,
105  bool existsUnresolved, const DtException* previousException = 0) throw()
106  : DtParseException("Missing Query", previousException)
107  , queryName(missingQueryName)
108  , queryExistsUnresolved(existsUnresolved)
109  {
110 
111  };
112 
113  virtual ~DtNamedQueryException() throw() {};
114 
115  std::string queryName;
116  //true if the missing query is simply not yet resolved, false if
117  //the missing query is actually non-existent in all the feature configuration.
119  };
120 
121  protected:
123  {
124  std::string name;
125  std::vector<std::string> tokens;
127  };
128 
129  typedef std::list<UnresolvedQuery> UnresolvedQueryList;
130 
133  virtual std::vector<std::string> extractQuery(std::vector<std::string>::iterator& itr,
134  const std::vector<std::string>& tokList);
135 
139  virtual DtQuery buildQuery(const std::vector<std::string>& queryToks);
140 
145  virtual DtQuery buildQueryAndBlock(const std::vector<std::string>& queryToks,
146  std::vector<std::string>::const_iterator& itr);
147 
151  virtual DtQuery buildFirstQuery(const std::vector<std::string>& queryToks,
152  std::vector<std::string>::const_iterator& itr);
153 
158  virtual DtQuery queryInsideParen(const std::vector<std::string>& parenToks,
159  std::vector<std::string>::const_iterator& itr);
160 
161  protected:
162  typedef tbb::recursive_mutex Mutex;
163  mutable Mutex myMutex;
164 
170 
171  //Map of named queries, defined in config file
173 
176 
178 
179  std::set<std::string> theQueryJoinTokens;
180  };
181 
182  std::ostream& operator<<(std::ostream&, const DtAttributeConfigParser&);
183 }

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)