GL Studio C++ Runtime API
live_component_lib_ref.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::LiveComponentLibRef class declaration.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2017 by 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 POSSIBILITY
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 #ifndef _LIVE_COMPONENT_LIB_REF_H
41 #define _LIVE_COMPONENT_LIB_REF_H
42 
43 #include "gls_include.h"
44 #include "gls_version.h"
45 #include <string>
46 
47 namespace disti
48 {
49 class DynamicLibrary;
50 class ComponentBase;
51 #ifdef GLES
52 class RSOInterfaceES1;
53 typedef RSOInterfaceES1 RsoImplBaseInterface;
54 #else
55 class RSOInterface1;
56 typedef RSOInterface1 RsoImplBaseInterface;
57 #endif
58 
59 class GlsRSOWrapper;
60 
61 /** This class is used to load a live component DLL (or .so) and allow
62  * easy calling of the live component library functions through the class methods.
63  * The library remains loaded until the reference is changed to another file
64  * or object destruction.
65  */
67 {
68 public:
69  /** Constructs a LiveComponentLibRef. */
70  static GLS_EXPORT LiveComponentLibRef* CreateInstance( const LiveComponentLibRef& );
71  /** Constructs a LiveComponentLibRef.
72  * \param filePath If a file path is specified, it will attempt a load immediatly.
73  */
74  static GLS_EXPORT LiveComponentLibRef* CreateInstance( const char* filePath = NULL );
75 
76  virtual GLS_EXPORT LiveComponentLibRef* CloneObject() const;
77 
78  /** Delete a LiveComponentLibRef instance using the
79  * correct delete operator.
80  */
81  virtual GLS_EXPORT void DeleteInstance();
82 
83  GLS_EXPORT const LiveComponentLibRef& operator=( const LiveComponentLibRef& );
84 
85  /** Sets the desired file name (.DLL or .so).
86  * Set to NULL to unload the current library. */
87  GLS_EXPORT void LoadLibrary( const char* fileName, const bool searchLibraryPath = false );
88  inline void UnloadLibrary() { LoadLibrary( NULL ); }
89 
90  /** Returns true if the library was sucessfully loaded. */
91  GLS_EXPORT bool Loaded() const;
92 
93  /** Returns the last error string or NULL if no error has occured. */
94  GLS_EXPORT const char* ErrorString() const;
95 
96  /** Returns the path to the library or NULL if no library is loaded. */
97  GLS_EXPORT const char* LoadedFilePath() const;
98 
99  /** Returns the built version info for the given class.
100  * \param className The name of the class to check.
101  * \returns If Loaded() is true and the className is valid, returns the compiler version associated with the given class.
102  * Otherwise, the return value is undefined. */
103  GLS_EXPORT const GlsBuiltVersionInfo& BuiltVersionInfo( const char* className ) const;
104 
105  /** \returns The DefaultClassName for the current LiveComponent Library if it is provided
106  * or NULL if it is unavailable. */
107  GLS_EXPORT const char* DefaultClassName() const;
108 
109  /** Attempts to create a LiveComponent instance of the given class.
110  * Call Destroy() on the object to delete it safely.
111  * Objects returned by this method may not be safe to use if the GlsBuiltVersionInfo
112  * for the LiveComponent Library does not match that of the container.
113  * \param className The name of the class to instanciate.
114  * \returns Pointer to the new instance if successful, NULL otherwise. */
115  GLS_EXPORT ComponentBase* CreateLiveComponent( const char* className ) const;
116 
117  /** Safely delete an object that was returned from
118  * CreateLiveComponent.
119  * \param className Must be the same name that was passed to CreateLiveComponent
120  * \param comp The component to delete */
121  GLS_EXPORT void DeleteLiveComponent( const char* className, ComponentBase* comp ) const;
122 
123  /** Attempts to create a LiveComponent instance of the given class using the safe interface.
124  * Call DestroyInstance() on the object to delete it safely.
125  * \param className The name of the class to instanciate.
126  * \param[out] RSOVersion The version number of the RSO and the returned interface
127  * \returns Pointer to the new instance if successful, NULL otherwise. */
128  GLS_EXPORT RsoImplBaseInterface* CreateRSOInterface( const char* className, unsigned int& RSOVersion ) const;
129 
130 protected:
131  /** Constructs a LiveComponentLibRef.
132  * Private - call CreateInstance instead
133  * \param filePath If a file path is specified, it will attempt a load immediatly.
134  */
135  LiveComponentLibRef( const char* filePath = NULL );
137  /** Destructor
138  * Private - call DeleteInstance instead.
139  */
140  virtual GLS_EXPORT ~LiveComponentLibRef();
141 
142  std::string _loadedFilePath;
143  DynamicLibrary* _lib;
144  char* _errorString;
145 
146  GLS_EXPORT void DeleteLibrary();
147 
148  GLS_EXPORT bool UpdateLoad();
149 
150  GLS_EXPORT void SetErrorString( const char* value );
151 
152  void EnableDialogs( const char* className, bool value ) const;
153 };
154 
155 } // namespace disti
156 
157 #endif
Definition: live_component_lib_ref.h:66
const char * DefaultClassName() const
const GlsBuiltVersionInfo & BuiltVersionInfo(const char *className) const
void LoadLibrary(const char *fileName, const bool searchLibraryPath=false)
A file for all GL Studio files to include.
Used for matching version of libraries and headers.
ComponentBase * CreateLiveComponent(const char *className) const
Definition: component_base.h:67
void DeleteLiveComponent(const char *className, ComponentBase *comp) const
static LiveComponentLibRef * CreateInstance(const LiveComponentLibRef &)
const char * ErrorString() const
Definition: rso_interface_1.h:60
RsoImplBaseInterface * CreateRSOInterface(const char *className, unsigned int &RSOVersion) const
Definition: dynamic_library.h:57
Definition: gls_version.h:210
const char * LoadedFilePath() const
LiveComponentLibRef(const char *filePath=NULL)
Definition: bmpimage.h:46
virtual void DeleteInstance()