DataDirector API
DDD_ConvertExpression.h
Go to the documentation of this file.
1 #ifndef _EXPRESSION_CONVERTER_H_
2 #define _EXPRESSION_CONVERTER_H_
3 
4 /*! \file DDD_ConvertExpression.h
5  \brief The DDD_ConvertExpression class.
6 
7  \par Copyright Information
8 
9  Copyright (c) 2012 The DiSTI Corporation.<br>
10  11301 Corporate Blvd; Suite 100<br>
11  Orlando, Florida 32817<br>
12  USA<br>
13  <br>
14  All rights reserved.<br>
15 
16  This Software contains proprietary trade secrets of DiSTI and may not be
17 reproduced, in whole or part, in any form, or by any means of electronic,
18 mechanical, or otherwise, without the written permission of DiSTI. Said
19 permission may be derived through the purchase of applicable DiSTI product
20 licenses which detail the distribution rights of this content and any
21 Derivative Works based on this or other copyrighted DiSTI Software.
22 
23  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
24 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
25 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
26 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
27 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
28 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
29 
30  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
31 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
32 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
33 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
34 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
35 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
36 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
37 EXCEED FIVE DOLLARS (US$5.00).
38 
39  The aforementioned terms and restrictions are governed by the laws of the
40 State of Florida and the United States of America.
41 
42 */
43 
44 
45 #include "DDD_ConvertBase.h"
46 #include "DDD_AttributeString.h"
47 #include "DDD_ConnectionEndpoint.h"
48 #include "expreval.h"
49 
50 namespace disti
51 {
52 
54 {
55 public:
56 
57  /* Function that implements the DDD_AttributeObserver interface
58  * \param attribute Pointer to the attribute whose value just
59  * changed
60  */
61  virtual void OnAttributeChanged(DDD_AttributeBase *attribute);
62 
63  /** Constructor
64  * \param observer An attribute observer that will observer the parameters of the converter
65  * All converter parameters must use this observer for the converter to work right in the
66  * Data Director GUI.
67  */
69 
70  /** Destructor */
71  virtual ~DDD_ConvertExpression();
72 
73  // Overrides from DDD_ConvertBase
74  virtual bool Convert(DDD_EndpointList& inputs, DDD_EndpointList& outputs);
75 
76  /** \return Returns true if the converter's configuration is valid
77  * \param inputs List of converter inputs
78  * \param outputs List of converter outputs
79  */
80  virtual bool ConfigurationValid(DDD_EndpointList& inputs, DDD_EndpointList& outputs);
81 
82  /** Initializes the converter, if necessary
83  * \param paramString
84  * \return True if the converter was successfully initialized.
85  */
86  virtual bool Init(const std::string &params);
87 
88  virtual int MinInputs();
89  virtual int MaxInputs();
90  virtual int MinOutputs();
91  virtual int MaxOutputs();
92 
93  /** \return Returns the class name of this converter
94  */
95  virtual const char* ClassName() { return CONVERT_EXPRESSION_CLASSNAME; }
96 
97  /** Used by the GUI to explain what this converter does
98  * \return Returns a string for the GUI to use
99  */
100  virtual const char* Description();
101 
102  static const char* CONVERT_EXPRESSION_CLASSNAME; /**< Classname string constant. Needed by the ConverterFactory */
103 
104 protected:
105 
106  /** Parse the input expression and convert it into a parse tree
107  */
108  void ParseExpression();
109 
110  /** Evaluate the stored parse tree, updating the inputs
111  * \param inputs The list of inputs for the connnection
112  * \param outputs The list of outputs for the connnection
113  */
114  virtual void Evaluate(DDD_EndpointList& inputs, DDD_EndpointList& outputs);
115 
116  DDD_AttributeString *_expression; /**< The C expression to interpret */
117 
118  bool _expressionValid; /**< True if the C expression is valid */
119  ExprEval::Expression *_parsedExpression; /**< The C expression as a parse tree */
120  ExprEval::ValueList *_vList; /**< The list of C variables */
121 };
122 
124 {
125 public:
126  /** ctor */
128 
129  static const char* CONVERT_SUBROUTINE_CLASSNAME; /**< Classname string constant. Needed by the ConverterFactory */
130 
131  /** \return Returns the class name of this converter
132  */
133  virtual const char* ClassName() { return CONVERT_SUBROUTINE_CLASSNAME; }
134 
135  /** Used by the GUI to explain what this converter does
136  * \return Returns a string for the GUI to use
137  */
138  virtual const char* Description();
139 
140  /** Initializes the converter, if necessary
141  * \param paramString
142  * \return True if the converter was successfully initialized.
143  */
144  virtual bool Init(const std::string &params);
145 
146 protected:
147 
148  /** Evaluate the stored parse tree, updating the inputs
149  * \param inputs The list of inputs for the connnection
150  * \param outputs The list of outputs for the connnection
151  */
152  virtual void Evaluate(DDD_EndpointList& inputs, DDD_EndpointList& outputs);
153 
154  /** Read the inputs to the subroutine
155  * \param inputs The list of inputs for the connnection
156  */
157  void ReadSubroutineInputs(DDD_EndpointList& inputs);
158 
159  /** Write the subroutine outputs to the attributes
160  * \param outputs The list of outputs for the connnection
161  */
162  void WriteSubroutineOutputs(DDD_EndpointList& outputs);
163 
164 
165 };
166 
167 } // end namespace disti
168 #endif
169 
virtual const char * ClassName()
Definition: DDD_ConvertExpression.h:133
The DDD_EndpintList class. A list of DDD_Endpoints.
Definition: DDD_ConnectionEndpoint.h:119
DataDirector attribute class corresponding to a string datatype.
Definition: DDD_AttributeString.h:52
A virtual interface class for all DataDirector attribute types.
Definition: DDD_AttributeBase.h:87
ExprEval::Expression * _parsedExpression
Definition: DDD_ConvertExpression.h:119
Abstract base class for all DDD_DataDirector converters.
Definition: DDD_ConvertBase.h:68
The DDD_ConvertBase class. Base class for Data Director converters.
A virtual interface class for observers of attributes. AttributeObserver-derived objects are able to ...
Definition: DDD_AttributeBase.h:66
Definition: DDD_ConvertExpression.h:53
DDD_AttributeString * _expression
Definition: DDD_ConvertExpression.h:116
bool _expressionValid
Definition: DDD_ConvertExpression.h:118
Definition: DDD_ConvertExpression.h:123
static const char * CONVERT_EXPRESSION_CLASSNAME
Definition: DDD_ConvertExpression.h:102
The DDD_AttributeString class. String attribute.
Definition: AttributeChangedEmitter.h:46
ExprEval::ValueList * _vList
Definition: DDD_ConvertExpression.h:120
static const char * CONVERT_SUBROUTINE_CLASSNAME
Definition: DDD_ConvertExpression.h:129
virtual const char * ClassName()
Definition: DDD_ConvertExpression.h:95