DataDirector API
DDD_XMLConfigMgr.h
Go to the documentation of this file.
1 /*! \file DDD_XMLConfigMgr.h
2 
3  \par Copyright Information
4 
5  Copyright (c) 2012 The DiSTI Corporation.<br>
6  11301 Corporate Blvd; Suite 100<br>
7  Orlando, Florida 32817<br>
8  USA<br>
9  <br>
10  All rights reserved.<br>
11 
12  This Software contains proprietary trade secrets of DiSTI and may not be
13 reproduced, in whole or part, in any form, or by any means of electronic,
14 mechanical, or otherwise, without the written permission of DiSTI. Said
15 permission may be derived through the purchase of applicable DiSTI product
16 licenses which detail the distribution rights of this content and any
17 Derivative Works based on this or other copyrighted DiSTI Software.
18 
19  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
20 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
21 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
22 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
24 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
25 
26  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
27 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
28 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
29 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
30 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
31 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
32 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
33 EXCEED FIVE DOLLARS (US$5.00).
34 
35  The aforementioned terms and restrictions are governed by the laws of the
36 State of Florida and the United States of America.
37 
38 */
39 
40 #ifndef DDD_XMLConfigMgr_H_
41 #define DDD_XMLConfigMgr_H_
42 
43 #include <string>
44 #include "DDD_AssetBase.h"
45 #include "DDD_AssetList.h"
46 #include "DDD_Connection.h"
47 #include "DDD_ConnectionList.h"
48 #include "DDD_ProgressPublisher.h"
49 #include "DDD_LogFacade.h"
50 
51 // LMX Parser classes
52 class c_WindowSettings;
53 class c_AssetParams;
54 class c_Assets;
55 class c_Connection;
56 class c_Connections;
57 class c_Endpoint;
58 class c_Converter;
59 
60 namespace disti
61 {
62 
63 typedef struct
64 {
65  std::string title;
66  unsigned int width;
67  unsigned int height;
68  int initialX;
69  int initialY;
70  std::string drawRate;
72 
73 /** \brief Abstract base class for any object that uses DDD_XMLConfigMgr */
74 class DDD_EXPORT XMLConfigTarget : public DDD_LogFacade
75 {
76 public:
77  /* Add asset to this target. Generally called from DDD_XMLConfigMgr whenever loading a new asset from XML.
78  * \param instanceName Asset instance name string. It must be a unique identifier.
79  * \param className Asset class name string.
80  * \param libName Filename of Dynamic library that contains this class. Only required if classname differs from libName.
81  * \param params List of attributes used for Asset initialization.
82  * \return Instance to new Asset if successful; NULL otherwise.
83  */
84  virtual DDD_AssetBase* AddAsset(const std::string &instanceName, const std::string &className, const std::string &libName, const DDD_AttributeList& params) = 0;
85 
86  /* Add connection to this target. Generally called from DDD_XMLConfigMgr whenever loading a new connection from XML.
87  * \param connection New Connection instance.
88  * \note Target is assumed to "own" connection pointer, and will be responsible for its deallocation.
89  */
90  virtual void AddConnection(DDD_Connection *connection) = 0;
91 
92  /* Finds asset instance by asset name.
93  * \param assetInstance String containing asset name.
94  * \return Pointer to asset if found; NULL otherwise.
95  */
96  virtual DDD_AssetBase* FindAsset(const std::string &assetInstance) = 0;
97 
98  /* Gets the Target's own asset list. Generally called from DDD_XMLConfigMgr whenever saving assets to XML.
99  * \return Reference to Target's internal asset list.
100  */
101  virtual DDD_AssetList &GetAssetList() = 0 ;
102 
103  /* Gets the Target's own connections list. Generally called from DDD_XMLConfigMgr whenever saving connections to XML.
104  * \return Reference to Target's internal connections list.
105  */
106  virtual DDD_ConnectionList &GetConnectionList() = 0;
107 
108  /* Sets the Window Attributes in the target.
109  * \param attribs The attributes to set
110  * \param currentWindow Number indicating which window these attributes correspond to.
111  */
112  virtual void AddXMLWindowAttributes( const WindowAttributes &attribs, unsigned int currentWindow ) {}
113 
114  /* \return Gets Window Attributes from target.
115  * \param currentWindow Number indicating which window these attributes correspond to.
116  */
117  virtual WindowAttributes GetXMLWindowAttributes( unsigned int currentWindow )
118  {
119  WindowAttributes attribs;
120 
121  attribs.height = 0;
122  attribs.width = 0;
123  attribs.initialX = 0;
124  attribs.initialY = 0;
125 
126  return attribs;
127  }
128 };
129 
130 
131 /** \brief Object that encapsulates XML loading and saving methods */
132 class DDD_EXPORT DDD_XMLConfigMgr : public DDD_ProgressPublisher, public DDD_LogFacade
133 {
134 private:
135  XMLConfigTarget *_target; /**< Current target for loading to and saving from. */
136  bool _readGUISettings; /**< If the target has a Viewer, GUI, or supports loading/saving window settings. */
137 
138 public:
139  /** Constructor */
141 
142  /** Destructor */
143  virtual ~DDD_XMLConfigMgr();
144 
145  /** Populates target with data given by XML file
146  * \param target Target instance that is currently using this XMLConfigMgr
147  * \param xmlFile Filename of XML file that is to be loaded.
148  * \param readGUISettings (Optional) If Target has a GUI or contains a DDD_Viewer, this should be true.
149  * \return true if configuration is successfully loaded, false otherwise.
150  */
151  bool LoadXML(XMLConfigTarget *target, const char *xmlFile, bool readGUISettings = false);
152 
153  /** Populates XML file with data given by target
154  * \param target Target instance that is currently using this XMLConfigMgr
155  * \param xmlFile Filename of XML file that is to be saved.
156  * \param readGUISettings (Optional) If Target has a GUI or contains a DDD_Viewer, this should be true.
157  * \return true if configuration is successfully saved, false otherwise.
158  */
159  bool SaveXML(XMLConfigTarget *target, const char *xmlFile, bool saveGUISettings = false);
160 
161 private:
162  // XML Parsing methods
163  void ReadWindowSettings(c_WindowSettings *windowSettings);
164  void ReadAssetParams(c_AssetParams *xmlParams,DDD_AttributeList &assetParams);
165  bool ReadAssets(c_Assets *assets);
166  void ReadEndpoint(c_Endpoint *endpoint,DDD_Connection *connection);
167  bool ReadConverter(c_Converter *converter,DDD_Connection *connection);
168  void ReadConnection(c_Connection *connection);
169  void ReadConnections(c_Connections *connections);
170 
171  /** Parses an expression that represents a connection and populates the connection
172  * \param connection The connection to populate
173  * \param expression The string containing the expression
174  */
175  void ParseExpression(DDD_Connection *connection,const char *expression);
176 };
177 
178 
179 } // end namespace disti
180 #endif
181 
Base class used by children of processes requesting periodic status updates.
Definition: DDD_ProgressPublisher.h:60
The DDD_Connection class. Base class for connections between assets.
A virtual interface class for all DataDirector assets.
Definition: DDD_AssetBase.h:115
Facade to provide a simpler interface to the DDD_Log singleton. Its second purpose is for decoupling;...
Definition: DDD_LogFacade.h:50
The DDD_AttributeList class. Maintains a list of Data Director attributes.
Definition: DDD_AttributeList.h:52
The DDD_AssetList class. Maintains a list of Data Director assets.
Definition: DDD_AssetList.h:51
The DDD_AssetBase class. Base class for Data Director assets.
Object that encapsulates XML loading and saving methods.
Definition: DDD_XMLConfigMgr.h:132
Publishes progress information to a progress subscriber for purposes of displaying a progress bar to ...
The DDD_Connection class. Base class for connections between assets.
Definition: DDD_Connection.h:54
Definition: DDD_XMLConfigMgr.h:63
Abstract base class for any object that uses DDD_XMLConfigMgr.
Definition: DDD_XMLConfigMgr.h:74
Definition: AttributeChangedEmitter.h:46