DataDirector API
DDD_StructuredMemoryAsset.h
Go to the documentation of this file.
1 /*! \file DDD_StructuredMemoryAsset.h
2  \brief The DDD_StructuredMemoryAsset. Data Director asset for ...
3 
4  \par Copyright Information
5 
6  Copyright (c) 2012 The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 
41 #ifndef _DDD_StructuredMemoryAsset_h_
42 #define _DDD_StructuredMemoryAsset_h_
43 
44 #include "DDD_AssetBase.h"
45 #include <string>
46 #include "timer.h"
47 #include "ChunkProducer.h"
48 
49 namespace disti
50 {
51 class DDD_AttributeDouble;
52 class DDD_AttributeString;
53 class DDD_AttributeBool;
54 class DDD_AttributeUInt;
55 
57 {
58 protected:
59 
60 public:
61 
62  static const char* DDD_STRUCTURED_MEMORY_ASSET_CLASS_NAME;
63 
64  /** Constructor
65  * \param container The container that owns this asset
66  */
68 
69  /** Destructor */
70  virtual ~DDD_StructuredMemoryAsset();
71 
72  /** Describes the Asset (for UI) */
73  virtual const char *Description() { return DDD_STRUCTURED_MEMORY_ASSET_CLASS_NAME; }
74 
75  /** Poll asset, put all "discovered" assets into _attributeList
76  * \pre _attributeList is empty
77  * \post _attributeList will contain the list of attributes discovered from the asset
78  */
79  virtual void PopulateAttributeList();
80 
81  /** calculate to pump the asset */
82  virtual void Calculate(double time);
83 
84  /** Start asset */
85  virtual void Start();
86 
87  /** Stop asset */
88  virtual void Stop();
89 
90  /** Pause asset */
91  virtual void Pause();
92 
93  /** Resume asset */
94  virtual void Resume();
95 
96  /** Is this asset currently running? */
97  virtual bool Live();
98 
99  /** Returns asset type (class) name */
100  virtual const char* ClassName();
101 
102  /** A callback method that will be called when the attribute being observed changes
103  * if this observer has registered to be notified on attribute change
104  * \param attribute A pointer to the attribute that changed
105  */
106  void OnAttributeChanged(DDD_AttributeBase *attribute);
107 
108  /** Sets the initialization parameters. The params specified will be merged with the parameters
109  * in the asset. Parameters that don't exist will be added. Parameters that do exist will be updated.
110  * \param params A set of parameter values to update or add.
111  */
112  void SetParams(const DDD_AttributeList &params);
113 
114 protected:
115  /** Creates a DataDirector attribute for the specified ChunkAttribute and also inserts it into
116  * the asset's attribute list and sets the back pointer between the StructuredMemory atribute and the
117  * DataDirector attribute
118  * \param attrName The name of the attribute, e.g. "datagram.attribute"
119  * \param attr The StructuredMemory attribute as specified by the XML config file
120  * \param receiveMode True if this attribute is a receive attribute (i.e. it gets set by an inbound chunk)
121  * False if this attribute is a send attribute (i.e. it gets set from an outbound chunk)
122  */
123  void CreateAttribute(std::string &attrName,ChunkAttribute *attr,bool receiveMode);
124 
125  /** Gets an attribute from the assets internal dictionary and add it to the list of
126  * published attributes for the asset.
127  * \param attributeName The name of the attribute to get
128  * \return A pointer to the attribute or NULL if it doesn't exist.
129  */
130  virtual DDD_AttributeBase* GetDictionaryAttribute(const char *attributeName);
131 
132  /** Add the exposed params to the attribute list
133  */
134  void AddExposedParamsAsAttributes();
135 
136  /** Processes the passed in params, copies into newParams only the params that are not also
137  * listed in the internal member variable _params
138  * \param params A list of parameters passed to the asset
139  * \param newParams The new list (returned) containing only what wasn't listed in _params
140  */
141  void RemoveBaseClassParams(const DDD_AttributeList &params,DDD_AttributeList &newParams);
142 
143 private:
144  /** Load the config file specified
145  * \param str The filename to of the file to load
146  */
147  void LoadConfigFile(const char *str);
148 
149 
150  /** \return Gets the list of initialization parameters for the object */
151  virtual DDD_AttributeList &GetParams();
152 
153  /** Temporaty list that has the combination of the StructuredMemory asset's params and the ChunkProducer's params */
154  DDD_AttributeList _mergedParams;
155 
156  DDD_AttributeString *_fileName; /**< Name of the data file to load */
157  DDD_AttributeDouble *_frameRate; /**< Frame rate of the data as a parameter */
158  DDD_AttributeDouble *_frameRateAtt; /**< Frame rate of the data as an exposed attribute */
159  DDD_AttributeBool *_receiveMode; /**< True if asset is receiving packets, false if it is sending */
160  DDD_AttributeUInt *_debugMode; /**< Type of debugging information to display in the console
161  0=None, 1=Light, 2=Verbose */
162  DDD_AttributeString *_dataBuffer; /**< .*/
163  DDD_AttributeString *_dataBufferAttrib; /**< .*/
164  DDD_AttributeUInt *_bufferLength; /**< .*/
165  DDD_AttributeUInt *_bufferLengthAttrib; /**< .*/
166 
167  Timer _frameTimer; /**< Timer used for polling port */
168 
169  ChunkProducer *_chunkProducer; /**< Produces attribute updates when chunks are received and
170  * decoded. */
171 
172  bool _reloadFile; /**< When changing an asset parameter, gets set to true when
173  * the file needs to be reloaded */
174 
175  bool _paused; /**< True when the asset is paused */
176 
177  bool _setParamsMode; /**< True for the duration of the SetParams call */
178 
179  unsigned char *_dataBufferPtr; /**< Buffer for the structured memory, copy of a pointer passed in by the user.*/
180 };
181 
182 } // end namespace disti
183 #endif
184 
The ChunkProducer class.
virtual const char * Description()
Definition: DDD_StructuredMemoryAsset.h:73
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
A virtual interface class for all DataDirector assets.
Definition: DDD_AssetBase.h:115
Definition: ChunkProducer.h:237
The DDD_AttributeList class. Maintains a list of Data Director attributes.
Definition: DDD_AttributeList.h:52
The disti::Timer class. An OS portable timing class.
Definition: DDD_StructuredMemoryAsset.h:56
A virtual interface class for observers of attributes. AttributeObserver-derived objects are able to ...
Definition: DDD_AttributeBase.h:66
The DDD_AssetBase class. Base class for Data Director assets.
Definition: timer.h:64
DataDirector attribute class corresponding to a boolean datatype.
Definition: DDD_AttributeBool.h:51
A virtual interface class for containers of assets. Allows assets to find each other, exchange events and update attributes of each other.
Definition: DDD_AssetBase.h:80
DataDirector attribute class corresponding to a double-precision float datatype.
Definition: DDD_AttributeDouble.h:51
DataDirector attribute class corresponding to a unsigned 32-bit integer datatype. ...
Definition: DDD_AttributeUInt.h:53
Definition: ChunkProducer.h:59
Definition: AttributeChangedEmitter.h:46