DataDirector API
DDD_Connection.h
Go to the documentation of this file.
1 #ifndef _DDD_Connection_h_
2 #define _DDD_Connection_h_
3 
4 /*! \file DDD_Connection.h
5  \brief The DDD_Connection class. Base class for connections between assets.
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 #include "DDD_ConnectionEndpoint.h"
45 #include "DDD_ConvertBase.h"
46 #include "dynamic_ptr_array.h"
47 
48 namespace disti
49 {
50 
51 
52 /** \brief The DDD_Connection class. Base class for connections between assets.
53  */
54 class DDD_EXPORT DDD_Connection : public DDD_AttributeObserver
55 {
56 public:
57  /** constructor */
59 
60  /** destructor */
61  ~DDD_Connection();
62 
63  /** process pending connections that have inputs with updated values */
64  static void ProcessPending();
65 
66  /** This method removes all connections from the the pending list.
67  */
68  static void ClearPendingList();
69 
70  /** Add an input to the connection at the end of the list
71  * \param input The input to add
72  */
73  bool AddInput( DDD_AttributeBase *input);
74 
75  /** Replace the input to the connection at specified index.
76  * \param input The input to add
77  * \param index The index to add at
78  */
79  bool ReplaceInput( DDD_AttributeBase *input, unsigned int index);
80 
81  /** Add an output to the connection at the end of the list
82  * \param output The input to add
83  */
84  bool AddOutput( DDD_AttributeBase *output);
85 
86  /** Replace the output to the connection at specified index.
87  * \param output The output to add
88  * \param index The index to add at
89  */
90  bool ReplaceOutput( DDD_AttributeBase *output, unsigned int index);
91 
92  /** Returns whether or not the specified output is already
93  * used as an output by this connection
94  * \param output The output to check
95  * \return True if the output is already used
96  */
97  bool IsOutputAlreadyUsed(DDD_AttributeBase *output);
98 
99  /** Iterates through the inputs and outputs of this connection and
100  * disconnects any endpoints that come from the specified asset
101  * \param asset The asset to disconnect
102  * \return The number of endpoints that were disconnected
103  */
104  int DisconnectAsset( DDD_AssetBase *asset );
105 
106  /** Iterates through the inputs and outputs of this connection and
107  * for each endpoint that has the same asset name as the specified asset
108  * that connection endpoint is reestablished. The purpose of this is to
109  * handle reconnection of endpoints in the case where the user deletes
110  * an asset in the editor and then loads a new asset
111  * \param asset Pointer to the asset to revalidate
112  */
113  void RevalidateEndpoints( DDD_AssetBase *asset );
114 
115  /** Remove the specified input endpoint from the connection
116  * \param index Index of the input endpoint to remove
117  */
118  void RemoveInput(unsigned int index);
119 
120  /** Remove the specified output endpoint from the connection
121  * \param endpoint Index of the output endpoint to remove
122  */
123  void RemoveOutput(unsigned int index);
124 
125  /** Chooses the converter function to use for this connection.
126  * \param className The class name of the converter. This will be used by the
127  * converter factory to dynamically load the converter.
128  * \param params The initialization parameters for the converter. The string
129  * must contain the parameters in the form param1=value1;param2=value2 etc.
130  * \return True if the converter was successfully loaded
131  */
132  bool UseConvertFunction(const std::string &className, const std::string &params);
133 
134  /** Chooses the converter function to use for this connection.
135  * \param className The class name of the converter. This will be used by the
136  * converter factory to dynamically load the converter.
137  * \return True if the converter was successfully loaded
138  */
139  bool UseConvertFunction(const std::string &className);
140 
141  /** Initializes the converter with the parameters specified as a string
142  * The string must contain the parameters in the form param1=value1;param2=value2 etc.
143  * The initialization string may contain the initial parameter values for the converter.
144  * \param params The parameters to the converter
145  * \return True if the parameters were accepted by the converter
146  */
147  bool InitConverter(const std::string& params);
148 
149  /** \return Returns true if all the endpoints for this connection are valid
150  * This is used by the GUI to indicate if a connection has invalid endpoints
151  */
152  bool AllEndpointsValid();
153 
154  /**\return Gets the list of input endpoints for this connection
155  */
156  DDD_EndpointList &GetInputs() { return _inputs; }
157 
158  /** \return Gets the list of output endpoints for this connection
159  */
160  DDD_EndpointList &GetOutputs() { return _outputs; }
161 
162  /** \return Gets a pointer to the converter for this connection or NULL if no
163  * converter has been set.
164  */
165  DDD_ConvertBase* GetConverter();
166 
167  /** Handles the case when the instance name of a connected asset is changed.
168  * Iterates through all connected endpoints and reconfigures them to use
169  * the new asset name.
170  * \param oldname The old name of the asset
171  * \param newname The new name of the asset
172  */
173  void NotifyAssetNameChange(const std::string& oldname, const std::string& newname);
174 
175  // From DDD_AttributeObserver interface
176  virtual void OnAttributeChanged(DDD_AttributeBase *attribute);
177 
178  /** Set the "DisplayNumber", which is used by the DataDirector GUI for sorting connections
179  * \param num The DisplayNumber to set
180  */
181  void DisplayNumber(int num) { _displayNumber = num; }
182 
183  /** \return Gets the "DisplayNumber", which is used by the DataDirector GUI
184  * for sorting connections
185  */
186  int DisplayNumber() const { return _displayNumber; }
187 
188  /** Allows whether connection can be forced to update when ForceProcess() is called
189  * \param allowForcePump If true, this connection will be processed when ForceProcess() is called.
190  * If false, it will ignore the request.
191  */
192  void AllowForcePump(bool allowForcePump);
193 
194  /** Adds connection to pending connections list, as long as force pumps are allowed */
195  void ForceProcess();
196 
197 private:
198 
199  /** This method adds this connection to pending connections list.
200  */
201  void AddToPendingProcesses();
202 
203  /** Rechecks the Valid status of all the connections endpoints and caches the
204  * result in _allEndpointsValid
205  */
206  void RecheckEndpoints();
207 
208  /** Iterates through the input endpoints and updates the names.
209  * Called whenever the converter changes or the inputs change.
210  */
211  void RefreshConverterInputEndpoints();
212 
213  /** Iterates through the output endpoints and updates the names.
214  * Called whenever the converter changes or the outputs change.
215  */
216  void RefreshConverterOutputEndpoints();
217 
218  /** Processes the inputs and executes the converter which will
219  * also notify the outputs if they have changed
220  * \return True if the converter was processed
221  */
222  bool Process();
223 
224 private:
225  int _displayNumber; /**< "DisplayNumber", used by GUI */
226  DDD_EndpointList _inputs; /**< The list of inputs for the connection */
227  DDD_EndpointList _outputs; /**< The list of outputs for the connection */
228  DDD_ConvertBase* _converter; /**< The converter to use */
229  bool _allEndpointsValid; /**< True if all connection endpoints are valid, used by GUI */
230 
231  /** The pending connections list. Whenever an input changes, any connections that are
232  * listening to that input are added to the pendingConnections list.
233  */
234  static DynamicPtrArray<DDD_Connection*> pendingConnections;
235 
236  bool _allowForcePump; /**< If false, this connection will not be updated when ForceProcess() is called */
237 
238 };
239 
240 } // end namespace disti
241 #endif
242 
The DDD_EndpintList class. A list of DDD_Endpoints.
Definition: DDD_ConnectionEndpoint.h:119
A virtual interface class for all DataDirector attribute types.
Definition: DDD_AttributeBase.h:87
Abstract base class for all DDD_DataDirector converters.
Definition: DDD_ConvertBase.h:68
DDD_EndpointList & GetOutputs()
Definition: DDD_Connection.h:160
A virtual interface class for all DataDirector assets.
Definition: DDD_AssetBase.h:115
The DDD_ConvertBase class. Base class for Data Director converters.
DDD_EndpointList & GetInputs()
Definition: DDD_Connection.h:156
A virtual interface class for observers of attributes. AttributeObserver-derived objects are able to ...
Definition: DDD_AttributeBase.h:66
void DisplayNumber(int num)
Definition: DDD_Connection.h:181
The DDD_Connection class. Base class for connections between assets.
Definition: DDD_Connection.h:54
int DisplayNumber() const
Definition: DDD_Connection.h:186
The disti::DynamicPtrArray class. A templated array of objects pointers capable of dynamically growin...
Definition: AttributeChangedEmitter.h:46