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
53 class ExprScalarAssignSpec : public ControlSpec {
54 public:
55 ExprScalarAssignSpec(const ExprAssignNode& node);
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
70 class ExprVectorAssignSpec : public ControlSpec {
71 public:
72 ExprVectorAssignSpec(const ExprAssignNode& node);
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;
83 Vec3d _val;
84 };
85
87 template <class T>
88 class ExprCurveAssignSpec : public ControlSpec {
89
90 public:
91 ExprCurveAssignSpec(const ExprAssignNode& node);
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 {
104 STRING,
105 FILE,
106 DIRECTORY
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;
120 Type _type;
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
SeExpr2::ControlSpec::ControlSpec
ControlSpec(const ExprNode &node)
Definition: ControlSpec.h:37
SeExpr2::ExprStrSpec::_str
std::string _str
Definition: ControlSpec.h:119
SeExpr2::ControlSpec::_name
std::string _name
Name of control.
Definition: ControlSpec.h:45
SeExpr2::ExprVectorAssignSpec::_min
double _min
Range of values.
Definition: ControlSpec.h:81
SeExpr2::ExprVectorAssignSpec::_val
Vec3d _val
Current Value.
Definition: ControlSpec.h:83
SeExpr2::ExprStrSpec::toString
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
Definition: ControlSpec.cpp:233
SeExpr2::Vec< double, 3, false >
SeExpr2::ExprVectorAssignSpec::match
static const ExprVectorAssignSpec * match(const ExprNode *node)
Definition: ControlSpec.cpp:152
SeExpr2::ExprCurveAssignSpec::_vec
std::vector< typename Curve< T >::CV > _vec
Control points of curve spline.
Definition: ControlSpec.h:99
SeExpr2::ExprScalarAssignSpec::_min
double _min
Range of values.
Definition: ControlSpec.h:64
SeExpr2::ExprNode
Definition: ExprNode.h:72
SeExpr2::ExprVectorAssignSpec::toString
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
Definition: ControlSpec.cpp:129
SeExpr2::ExprStrSpec::_type
Type _type
Definition: ControlSpec.h:120
SeExpr2::ExprStrSpec::FILE
Definition: ControlSpec.h:105
SeExpr2::ExprVectorAssignSpec::value
const Vec3d & value() const
Definition: ControlSpec.h:74
SeExpr2::SpecExaminer::~SpecExaminer
~SpecExaminer()
Definition: ControlSpec.cpp:32
SeExpr2::ExprScalarAssignSpec::ExprScalarAssignSpec
ExprScalarAssignSpec(const ExprAssignNode &node)
Definition: ControlSpec.cpp:89
SeExpr2::ExprAssignNode
Node that compute a local variable assignment.
Definition: ExprNode.h:355
SeExpr2::ControlSpec::_end
int _end
End position of text in original source.
Definition: ControlSpec.h:49
SeExpr2::ExprCurveAssignSpec::_lookupText
std::string _lookupText
Lookup subexpression text.
Definition: ControlSpec.h:97
SeExpr2::ExprCurveAssignSpec::toString
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
Definition: ControlSpec.cpp:161
SeExpr2::Examiner
Definition: ExprWalker.h:33
SeExpr2::ExprScalarAssignSpec::toString
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
Definition: ControlSpec.cpp:101
SeExpr2::ExprVectorAssignSpec::_max
double _max
Definition: ControlSpec.h:81
SeExpr2::ExprStrSpec::DIRECTORY
Definition: ControlSpec.h:106
SeExpr2::ExprScalarAssignSpec::_max
double _max
Definition: ControlSpec.h:64
SeExpr2
Definition: Context.h:22
SeExpr2::SpecExaminer::examine
virtual bool examine(const ExprNode *examinee)
Definition: ControlSpec.cpp:38
ExprNode.h
SeExpr2::ExprScalarAssignSpec::value
double value() const
Definition: ControlSpec.h:57
SeExpr2::ExprStrSpec::match
static const ExprStrSpec * match(const ExprNode *node)
Definition: ControlSpec.cpp:253
ExprWalker.h
SeExpr2::ExprCurveAssignSpec::ExprCurveAssignSpec
ExprCurveAssignSpec(const ExprAssignNode &node)
Definition: ControlSpec.cpp:139
SeExpr2::ExprStrSpec::ExprStrSpec
ExprStrSpec(const ExprStrNode &node, char *name, Type type)
Takes name and type comments and takes ownership of them!
Definition: ControlSpec.h:111
SeExpr2::SpecExaminer::_specList
std::vector< const ControlSpec * > _specList
Definition: ControlSpec.h:143
SeExpr2::ExprCurveAssignSpec::match
static const ExprCurveAssignSpec * match(const ExprNode *node)
Definition: ControlSpec.cpp:174
SeExpr2::SpecExaminer
Examiner that builds a list of specs potentially used in widgets (for qdgui)
Definition: ControlSpec.h:124
SeExpr2::ExprCurveAssignSpec
Curve assignment expression. Assignment of curve to a variable.
Definition: ControlSpec.h:88
SeExpr2::ControlSpec
Generic Expression control specification.
Definition: ControlSpec.h:35
SeExpr2::ExprVectorAssignSpec
Variable equals vector control specification.
Definition: ControlSpec.h:70
SeExpr2::ExprStrSpec
Definition: ControlSpec.h:102
SeExpr2::ExprScalarAssignSpec::_val
double _val
Current Value.
Definition: ControlSpec.h:66
SeExpr2::ControlSpec::~ControlSpec
virtual ~ControlSpec()
Definition: ControlSpec.h:38
SeExpr2::ControlSpec::toString
virtual std::string toString() const =0
Generates a replacement string based on changes to the spec.
SeExpr2::ExprStrSpec::STRING
Definition: ControlSpec.h:104
SeExpr2::ExprStrNode
Node that stores a string.
Definition: ExprNode.h:502
SeExpr2::ExprVectorAssignSpec::ExprVectorAssignSpec
ExprVectorAssignSpec(const ExprAssignNode &node)
Definition: ControlSpec.cpp:115
SeExpr2::ExprScalarAssignSpec
Variable equals scalar control specification.
Definition: ControlSpec.h:53
SeExpr2::ControlSpec::_start
int _start
Start position of text in original source.
Definition: ControlSpec.h:47
SeExpr2::SpecExaminer::end
const std::vector< const ControlSpec * >::const_iterator end() const
Definition: ControlSpec.cpp:63
SeExpr2::SpecExaminer::length
int length() const
Definition: ControlSpec.h:133
SeExpr2::SpecExaminer::reset
virtual void reset()
Definition: ControlSpec.h:130
Curve.h
SeExpr2::SpecExaminer::begin
std::vector< const ControlSpec * >::const_iterator begin() const
Definition: ControlSpec.cpp:59
SeExpr2::ExprStrSpec::Type
Type
Definition: ControlSpec.h:103
SeExpr2::ExprScalarAssignSpec::match
static const ExprScalarAssignSpec * match(const ExprNode *node)
Definition: ControlSpec.cpp:109
SeExpr2::SpecExaminer::spec
const ControlSpec * spec(int i) const
Definition: ControlSpec.h:136