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