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
32namespace SeExpr2 {
33
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
87template <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
102class ExprStrSpec : public ControlSpec {
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
124class SpecExaminer : public Examiner<true> {
125
126 public:
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
Generic Expression control specification.
Definition ControlSpec.h:35
std::string _name
Name of control.
Definition ControlSpec.h:45
int _end
End position of text in original source.
Definition ControlSpec.h:49
virtual std::string toString() const =0
Generates a replacement string based on changes to the spec.
ControlSpec(const ExprNode &node)
Definition ControlSpec.h:37
int _start
Start position of text in original source.
Definition ControlSpec.h:47
Node that compute a local variable assignment.
Definition ExprNode.h:355
Curve assignment expression. Assignment of curve to a variable.
Definition ControlSpec.h:88
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.
static const ExprCurveAssignSpec * match(const ExprNode *node)
std::vector< typename Curve< T >::CV > _vec
Control points of curve spline.
Definition ControlSpec.h:99
Variable equals scalar control specification.
Definition ControlSpec.h:53
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
double _val
Current Value.
Definition ControlSpec.h:66
double _min
Range of values.
Definition ControlSpec.h:64
static const ExprScalarAssignSpec * match(const ExprNode *node)
Node that stores a string.
Definition ExprNode.h:502
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
ExprStrSpec(const ExprStrNode &node, char *name, Type type)
Takes name and type comments and takes ownership of them!
static const ExprStrSpec * match(const ExprNode *node)
Variable equals vector control specification.
Definition ControlSpec.h:70
virtual std::string toString() const
Generates a replacement string based on changes to the spec.
double _min
Range of values.
Definition ControlSpec.h:81
Vec3d _val
Current Value.
Definition ControlSpec.h:83
const Vec3d & value() const
Definition ControlSpec.h:74
static const ExprVectorAssignSpec * match(const ExprNode *node)
Examiner that builds a list of specs potentially used in widgets (for qdgui)
const ControlSpec * spec(int i) const
std::vector< const ControlSpec * > _specList
std::vector< constControlSpec * >::const_iterator const end() const
std::vector< constControlSpec * >::const_iterator begin() const
virtual void reset()
virtual bool examine(const ExprNode *examinee)