SeExpr
ControlSpec.h
Go to the documentation of this file.
1 /*
2  Copyright Disney Enterprises, Inc. All rights reserved.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License
6  and the following modification to it: Section 6 Trademarks.
7  deleted and replaced with:
8 
9  6. Trademarks. This License does not grant permission to use the
10  trade names, trademarks, service marks, or product names of the
11  Licensor and its affiliates, except as required for reproducing
12  the content of the NOTICE file.
13 
14  You may obtain a copy of the License at
15  http://www.apache.org/licenses/LICENSE-2.0
16 */
17 
18 #ifndef ControlSpec_h
19 #define ControlSpec_h
20 
21 #ifndef MAKEDEPEND
22 #include <string.h>
23 #include <string>
24 #include <vector>
25 #endif
26 #include <cstdio>
27 
28 #include <SeExpr2/ExprWalker.h>
29 #include <SeExpr2/ExprNode.h>
30 #include <SeExpr2/Curve.h>
31 
32 namespace SeExpr2 {
33 
35 class ControlSpec {
36  public:
37  ControlSpec(const ExprNode& node) : _start(node.startPos()), _end(node.endPos()) {};
38  virtual ~ControlSpec() {};
39 
41  virtual std::string toString() const = 0;
42 
43  protected:
45  std::string _name;
47  int _start;
49  int _end;
50 };
51 
54  public:
56  virtual std::string toString() const;
57  inline double value() const {
58  return _val;
59  };
60  static const ExprScalarAssignSpec* match(const ExprNode* node);
61 
62  private:
64  double _min, _max;
66  double _val;
67 };
68 
71  public:
73  virtual std::string toString() const;
74  inline const Vec3d& value() const {
75  return _val;
76  };
77  static const ExprVectorAssignSpec* match(const ExprNode* node);
78 
79  private:
81  double _min, _max;
84 };
85 
87 template <class T>
89 
90  public:
92  virtual std::string toString() const;
93  static const ExprCurveAssignSpec* match(const ExprNode* node);
94 
95  private:
97  std::string _lookupText;
99  std::vector<typename Curve<T>::CV> _vec;
100 };
101 
102 class ExprStrSpec : public ControlSpec {
103  enum Type {
107  };
108 
109  public:
111  ExprStrSpec(const ExprStrNode& node, char* name, Type type) : ControlSpec(node), _str(node.str()), _type(type) {
112  _name = name;
113  }
114 
115  virtual std::string toString() const;
116  static const ExprStrSpec* match(const ExprNode* node);
117 
118  private:
119  std::string _str;
121 };
122 
124 class SpecExaminer : public Examiner<true> {
125 
126  public:
127  ~SpecExaminer();
128 
129  virtual bool examine(const ExprNode* examinee);
130  virtual void reset() {
131  _specList.clear();
132  };
133  inline int length() const {
134  return _specList.size();
135  };
136  inline const ControlSpec* spec(int i) const {
137  return _specList[i];
138  };
139  inline std::vector<const ControlSpec*>::const_iterator begin() const;
140  inline std::vector<const ControlSpec*>::const_iterator const end() const;
141 
142  private:
143  std::vector<const ControlSpec*> _specList;
144 };
145 }
146 #endif
ExprStrSpec(const ExprStrNode &node, char *name, Type type)
Takes name and type comments and takes ownership of them!
Definition: ControlSpec.h:111
Vec3d _val
Current Value.
Definition: ControlSpec.h:83
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
virtual std::string toString() const =0
Generates a replacement string based on changes to the spec.
static const ExprCurveAssignSpec * match(const ExprNode *node)
Variable equals scalar control specification.
Definition: ControlSpec.h:53
static const ExprVectorAssignSpec * match(const ExprNode *node)
double _min
Range of values.
Definition: ControlSpec.h:81
int length() const
Definition: ControlSpec.h:133
double _val
Current Value.
Definition: ControlSpec.h:66
double _min
Range of values.
Definition: ControlSpec.h:64
Variable equals vector control specification.
Definition: ControlSpec.h:70
Node that stores a string.
Definition: ExprNode.h:499
Generic Expression control specification.
Definition: ControlSpec.h:35
std::string _name
Name of control.
Definition: ControlSpec.h:45
ExprVectorAssignSpec(const ExprAssignNode &node)
virtual bool examine(const ExprNode *examinee)
Definition: ControlSpec.cpp:38
Curve assignment expression. Assignment of curve to a variable.
Definition: ControlSpec.h:88
ExprScalarAssignSpec(const ExprAssignNode &node)
Definition: ControlSpec.cpp:89
const Vec3d & value() const
Definition: ControlSpec.h:74
const ControlSpec * spec(int i) const
Definition: ControlSpec.h:136
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
std::vector< const ControlSpec * >::const_iterator begin() const
Definition: ControlSpec.cpp:59
int _start
Start position of text in original source.
Definition: ControlSpec.h:47
ExprCurveAssignSpec(const ExprAssignNode &node)
ControlSpec(const ExprNode &node)
Definition: ControlSpec.h:37
Node that compute a local variable assignment.
Definition: ExprNode.h:354
int _end
End position of text in original source.
Definition: ControlSpec.h:49
virtual void reset()
Definition: ControlSpec.h:130
static const ExprScalarAssignSpec * match(const ExprNode *node)
std::vector< const ControlSpec * > _specList
Definition: ControlSpec.h:143
virtual ~ControlSpec()
Definition: ControlSpec.h:38
std::string _lookupText
Lookup subexpression text.
Definition: ControlSpec.h:97
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
Examiner that builds a list of specs potentially used in widgets (for qdgui)
Definition: ControlSpec.h:124
std::vector< typename Curve< T >::CV > _vec
Control points of curve spline.
Definition: ControlSpec.h:99
static const ExprStrSpec * match(const ExprNode *node)
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
std::vector< const ControlSpec * >::const_iterator const end() const
Definition: ControlSpec.cpp:63