VR-Forces 4.2 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 
38  boost::optional<DtFeature::Attribute> evaluate() const;
39 
41  boost::optional<DtFeature::Attribute> evaluate(const DtFeature& feature) const;
42 
43  void print(std::ostream&) const;
44 
45  std::string myQueryName;
48  std::string myExpression;
49  };
50 
51  std::ostream& operator<<(std::ostream&, const DtFeatureTransform&);
52 
57  {
58  public:
59  typedef std::map<std::string, DtQuery> DtQueryMap;
60  typedef std::vector<DtFeatureTransform> TransformVector;
61 
63  virtual ~DtAttributeConfigParser();
64 
68  virtual bool readAttributeConfig(const std::string& filename, const DtQuery& schema= DtQuery());
69 
71  virtual DtQueryMap queryMap() const;
72 
74  virtual DtQuery findQuery(std::string) const;
75 
77  virtual TransformVector transforms() const;
78 
79  virtual void print(std::ostream&) const;
80 
81  virtual std::string pprintQueries() const;
82  virtual std::string pprintTransforms() const;
83 
93  virtual void resolveNamedQueries();
94 
97  {
98  public:
99  DtParseException(const char *errorMessage,
100  const DtException *previousException = 0) throw()
101  : DtException(errorMessage, previousException) {};
102 
103  virtual ~DtParseException() throw() {};
104  };
105 
107  {
108  public:
109  DtNamedQueryException(std::string missingQueryName,
110  bool existsUnresolved, const DtException* previousException = 0) throw()
111  : DtParseException("Missing Query", previousException)
112  , queryName(missingQueryName)
113  , queryExistsUnresolved(existsUnresolved)
114  {
115 
116  };
117 
118  virtual ~DtNamedQueryException() throw() {};
119 
120  std::string queryName;
121  //true if the missing query is simply not yet resolved, false if
122  //the missing query is actually non-existent in all the feature configuration.
124  };
125 
129  virtual DtQuery buildQuery(const std::vector<std::string>& queryToks);
130 
133  virtual DtQuery buildQueryNoThrow(std::string line);
134 
135  protected:
137  {
138  std::string name;
139  std::vector<std::string> tokens;
141  };
142 
143  typedef std::list<UnresolvedQuery> UnresolvedQueryList;
144 
147  virtual std::vector<std::string> extractQuery(std::vector<std::string>::iterator& itr,
148  const std::vector<std::string>& tokList);
149 
154  virtual DtQuery buildQueryAndBlock(const std::vector<std::string>& queryToks,
155  std::vector<std::string>::const_iterator& itr);
156 
160  virtual DtQuery buildFirstQuery(const std::vector<std::string>& queryToks,
161  std::vector<std::string>::const_iterator& itr);
162 
167  virtual DtQuery queryInsideParen(const std::vector<std::string>& parenToks,
168  std::vector<std::string>::const_iterator& itr);
169 
170  protected:
171  typedef tbb::recursive_mutex Mutex;
172  mutable Mutex myMutex;
173 
179 
180  //Map of named queries, defined in config file
182 
185 
187 
188  std::set<std::string> theQueryJoinTokens;
189  };
190 
191  std::ostream& operator<<(std::ostream&, const DtAttributeConfigParser&);
192 }

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)