Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGSharedObjectHandler.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2003 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGSHAREDOBJECTHANDLER_H_
00040 #define _OSGSHAREDOBJECTHANDLER_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 
00050 //---------------------------------------------------------------------------
00051 //  Includes
00052 //---------------------------------------------------------------------------
00053 
00054 #include "OSGBaseTypes.h"
00055 #include "OSGMemoryObject.h"
00056 
00057 #include <map>
00058 #include <vector>
00059 
00060 OSG_BEGIN_NAMESPACE
00061 
00062 //---------------------------------------------------------------------------
00063 //  Forward References
00064 //---------------------------------------------------------------------------
00065 
00066 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00067 
00068 class SharedObjectHandler;
00069 class SharedObject;
00070 
00071 #endif
00072 
00073 //---------------------------------------------------------------------------
00074 //   Types
00075 //---------------------------------------------------------------------------
00076 
00077 #ifdef WIN32
00078 typedef HMODULE  SharedHandle;
00079 #else
00080 typedef void    *SharedHandle;
00081 #endif
00082 
00083 typedef void *AnonSymbolHandle;
00084 
00085 //---------------------------------------------------------------------------
00086 //  Class
00087 //---------------------------------------------------------------------------
00088 
00092 typedef OSG::SharedObject *SharedObjectP;
00093 
00097 class OSG_BASE_DLLMAPPING SharedObject : public MemoryObject
00098 {
00099   public:
00100 
00101     //-----------------------------------------------------------------------
00102     //   constants                                                           
00103     //-----------------------------------------------------------------------
00104 
00105     //-----------------------------------------------------------------------
00106     //   enums                                                               
00107     //-----------------------------------------------------------------------
00108 
00109     enum SharedObjectType
00110     {
00111         Invalid       = 0x0000,
00112         Application   = 0x0001,
00113         SharedLibrary = 0x0002
00114     };
00115 
00116     //-----------------------------------------------------------------------
00117     //   types                                                               
00118     //-----------------------------------------------------------------------
00119 
00120   private:
00121 
00122     //-----------------------------------------------------------------------
00123     //   enums                                                               
00124     //-----------------------------------------------------------------------
00125 
00126     //-----------------------------------------------------------------------
00127     //   types                                                               
00128     //-----------------------------------------------------------------------
00129 
00130     typedef MemoryObject Inherited;
00131 
00132     //-----------------------------------------------------------------------
00133     //   friend classes                                                      
00134     //-----------------------------------------------------------------------
00135 
00136     friend class SharedObjectHandler;
00137 
00138     //-----------------------------------------------------------------------
00139     //   friend functions                                                    
00140     //-----------------------------------------------------------------------
00141 
00142     //-----------------------------------------------------------------------
00143     //   class variables                                                     
00144     //-----------------------------------------------------------------------
00145 
00146     //-----------------------------------------------------------------------
00147     //   class functions                                                     
00148     //-----------------------------------------------------------------------
00149 
00150     //-----------------------------------------------------------------------
00151     //   instance variables                                                  
00152     //-----------------------------------------------------------------------
00153 
00154     //-----------------------------------------------------------------------
00155     //   instance functions                                                  
00156     //-----------------------------------------------------------------------
00157 
00158     // prohibit default functions (move to 'public' if you need one)
00159     SharedObject(const SharedObject &source);
00160     // prohibit default functions (move to 'public' if you need one)
00161     void operator =(const SharedObject &source);
00162 
00163   protected:
00164 
00165     //-----------------------------------------------------------------------
00166     //   enums                                                               
00167     //-----------------------------------------------------------------------
00168 
00169     //-----------------------------------------------------------------------
00170     //   types                                                               
00171     //-----------------------------------------------------------------------
00172 
00173     //-----------------------------------------------------------------------
00174     //   class variables                                                     
00175     //-----------------------------------------------------------------------
00176 
00177     static Char8 _szApplicationObjectName[];
00178 
00179     //-----------------------------------------------------------------------
00180     //   class functions                                                     
00181     //-----------------------------------------------------------------------
00182 
00183     //-----------------------------------------------------------------------
00184     //   instance variables                                                  
00185     //-----------------------------------------------------------------------
00186 
00187     std::string      _szName;
00188     SharedHandle     _pHandle;
00189 
00190     SharedObjectType _type;    
00191 
00192     //-----------------------------------------------------------------------
00193     //   instance functions                                                  
00194     //-----------------------------------------------------------------------
00195 
00196     SharedObject(const Char8 *szName);
00197 
00198     virtual ~SharedObject(void); 
00199 
00200     bool close(void);
00201 
00202   public :
00203 
00204     //-----------------------------------------------------------------------
00205     //   class functions                                                     
00206     //-----------------------------------------------------------------------
00207 
00208     //-----------------------------------------------------------------------
00209     //   instance functions                                                  
00210     //-----------------------------------------------------------------------
00211 
00212     /*------------------------- your_category -------------------------------*/
00213 
00214           bool             open     (      void               );
00215           AnonSymbolHandle getSymbol(const Char8 *szSymbolName);
00216 
00217           bool             isOpen   (      void               );
00218 
00219           bool             reOpen   (      void               );
00220 
00221     const std::string     &getName  (      void               );
00222     const Char8           *getCName (      void               );
00223 
00224     /*------------------------- your_operators ------------------------------*/
00225 
00226     /*------------------------- assignment ----------------------------------*/
00227 
00228     void dump(void);
00229 
00230     /*------------------------- comparison ----------------------------------*/
00231 };
00232 
00233 //---------------------------------------------------------------------------
00234 //  Class
00235 //---------------------------------------------------------------------------
00236 
00237 
00241 typedef OSG::SharedObjectHandler *SharedObjectHandlerP;
00242 
00246 class OSG_BASE_DLLMAPPING SharedObjectHandler
00247 {
00248   public:
00249 
00250     //-----------------------------------------------------------------------
00251     //   constants                                                           
00252     //-----------------------------------------------------------------------
00253 
00254     //-----------------------------------------------------------------------
00255     //   enums                                                               
00256     //-----------------------------------------------------------------------
00257 
00258     //-----------------------------------------------------------------------
00259     //   types                                                               
00260     //-----------------------------------------------------------------------
00261 
00262     typedef std::map<std::string, SharedObjectP>     SharedObjectMap;
00263 
00264     typedef SharedObjectMap::iterator                SharedObjectMapIt;
00265 
00266     typedef SharedObjectMap::const_iterator          SharedObjectMapConstIt;
00267 
00268 
00269     typedef std::vector<std::string>                 NameStore;
00270     typedef std::vector<std::string>::iterator       NameStoreIt;
00271     typedef std::vector<std::string>::const_iterator NameStoreConstIt;
00272 
00273   private:
00274 
00275     //-----------------------------------------------------------------------
00276     //   enums                                                               
00277     //-----------------------------------------------------------------------
00278 
00279     //-----------------------------------------------------------------------
00280     //   types                                                               
00281     //-----------------------------------------------------------------------
00282 
00283     //-----------------------------------------------------------------------
00284     //   friend classes                                                      
00285     //-----------------------------------------------------------------------
00286 
00287     //-----------------------------------------------------------------------
00288     //   friend functions                                                    
00289     //-----------------------------------------------------------------------
00290 
00291     friend  OSG_BASE_DLLMAPPING bool osgInit(Int32 argc, Char8 **argv);
00292     friend  OSG_BASE_DLLMAPPING bool osgExit(void                    );
00293 
00294     //-----------------------------------------------------------------------
00295     //   class variables                                                     
00296     //-----------------------------------------------------------------------
00297 
00298     //-----------------------------------------------------------------------
00299     //   class functions                                                     
00300     //-----------------------------------------------------------------------
00301 
00302     //-----------------------------------------------------------------------
00303     //   instance variables                                                  
00304     //-----------------------------------------------------------------------
00305 
00306     //-----------------------------------------------------------------------
00307     //   instance functions                                                  
00308     //-----------------------------------------------------------------------
00309 
00310     // prohibit default functions (move to 'public' if you need one)
00311     SharedObjectHandler(const SharedObjectHandler &source);
00312     // prohibit default functions (move to 'public' if you need one)
00313     void operator =(const SharedObjectHandler &source);
00314 
00315   protected:
00316 
00317     //-----------------------------------------------------------------------
00318     //   enums                                                               
00319     //-----------------------------------------------------------------------
00320 
00321     //-----------------------------------------------------------------------
00322     //   types                                                               
00323     //-----------------------------------------------------------------------
00324 
00325     //-----------------------------------------------------------------------
00326     //   class variables                                                     
00327     //-----------------------------------------------------------------------
00328 
00329     static SharedObjectHandlerP _the;
00330 
00331     //-----------------------------------------------------------------------
00332     //   class functions                                                     
00333     //-----------------------------------------------------------------------
00334 
00335     //-----------------------------------------------------------------------
00336     //   instance variables                                                  
00337     //-----------------------------------------------------------------------
00338 
00339     SharedObjectMap _mSharedObjects;
00340     
00341     NameStore       _vLoadedNames;
00342 
00343     //-----------------------------------------------------------------------
00344     //   instance functions                                                  
00345     //-----------------------------------------------------------------------
00346 
00347     SharedObjectHandler(void);
00348 
00349     virtual ~SharedObjectHandler(void); 
00350 
00351     bool initialize(void);
00352     void terminate (void);
00353 
00354   public :
00355 
00356     //-----------------------------------------------------------------------
00357     //   class functions                                                     
00358     //-----------------------------------------------------------------------
00359 
00360     static SharedObjectHandlerP the(void);
00361 
00362     //-----------------------------------------------------------------------
00363     //   instance functions                                                  
00364     //-----------------------------------------------------------------------
00365 
00366     SharedObjectP getSharedObject   (const Char8         *szName );
00367     SharedObjectP getOSGSharedObject(const Char8         *szName );
00368     SharedObjectP findSharedObject  (const Char8         *szName ) const;
00369 
00370     void             removeSharedObject(const Char8         *szName );
00371     void             removeSharedObject(      SharedObjectP  pObject);
00372 
00373     /*------------------------- your_category -------------------------------*/
00374 
00375     void registerLoadedObject(const Char8 *szName);
00376 
00377     /*------------------------- your_operators ------------------------------*/
00378 
00379     /*------------------------- assignment ----------------------------------*/
00380     
00381     /*------------------------- comparison ----------------------------------*/
00382 
00383     void dump(void);
00384 
00385     /*------------------------- comparison ----------------------------------*/
00386 };
00387 
00388 OSG_END_NAMESPACE
00389 
00390 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00391 
00392 #define OSGSHAREDOBJECTHANDLER_HEADER_CVSID "@(#)$Id: $"
00393 
00394 #endif
00395 
00396 #endif /* _OSGSHAREDOBJECTHANDLER_H_ */

Generated on Thu Aug 25 04:09:52 2005 for OpenSG by  doxygen 1.4.3