LibraryNSPR.h

Go to the documentation of this file.
00001 /****************** <VPR heading BEGIN do not edit this line> *****************
00002  *
00003  * VR Juggler Portable Runtime
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Patrick Hartling, Kevin Meinert, Carolina Cruz-Neira
00007  *
00008  * -----------------------------------------------------------------
00009  * File:          $RCSfile$
00010  * Date modified: $Date: 2005-01-17 22:34:01 -0600 (Mon, 17 Jan 2005) $
00011  * Version:       $Revision: 16635 $
00012  * -----------------------------------------------------------------
00013  *
00014  ****************** <VPR heading END do not edit this line> ******************/
00015 
00016 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00017  *
00018  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00019  *
00020  * Original Authors:
00021  *   Allen Bierbaum, Christopher Just,
00022  *   Patrick Hartling, Kevin Meinert,
00023  *   Carolina Cruz-Neira, Albert Baker
00024  *
00025  * This library is free software; you can redistribute it and/or
00026  * modify it under the terms of the GNU Library General Public
00027  * License as published by the Free Software Foundation; either
00028  * version 2 of the License, or (at your option) any later version.
00029  *
00030  * This library is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00033  * Library General Public License for more details.
00034  *
00035  * You should have received a copy of the GNU Library General Public
00036  * License along with this library; if not, write to the
00037  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00038  * Boston, MA 02111-1307, USA.
00039  *
00040  *************** <auto-copyright.pl END do not edit this line> ***************/
00041 
00042 #ifndef _VPR_LIBRARY_NSPR_H_
00043 #define _VPR_LIBRARY_NSPR_H_
00044 
00045 #include <vpr/vprConfig.h>
00046 
00047 #include <stdlib.h>
00048 #include <string>
00049 #include <prlink.h>
00050 
00051 #include <vpr/Util/ReturnStatus.h>
00052 
00053 
00054 namespace vpr
00055 {
00056 
00069 class VPR_CLASS_API LibraryNSPR
00070 {
00071 public:
00081    LibraryNSPR(const std::string& name)
00082       : mName(name)
00083       , mLibrary(NULL)
00084    {
00085       ;
00086    }
00087 
00097    LibraryNSPR()
00098       : mName("")
00099       , mLibrary(NULL)
00100    {
00101       ;
00102    }
00103 
00107    LibraryNSPR(const LibraryNSPR& lib)
00108       : mName("")
00109       , mLibrary(NULL)
00110    {
00111       copy(lib);
00112    }
00113 
00117    ~LibraryNSPR()
00118    {
00119       if ( NULL != mLibrary )
00120       {
00121          unload();
00122       }
00123    }
00124 
00128    LibraryNSPR& operator=(const LibraryNSPR& lib)
00129    {
00130       copy(lib);
00131       return *this;
00132    }
00133 
00137    const std::string& getName() const
00138    {
00139       return mName;
00140    }
00141 
00151    vpr::ReturnStatus load();
00152 
00161    vpr::ReturnStatus unload();
00162 
00169    bool isLoaded() const
00170    {
00171       return mLibrary != NULL;
00172    }
00173 
00175 
00191    void* findSymbol(const char* symbolName)
00192    {
00193       return PR_FindSymbol(mLibrary, symbolName);
00194    }
00195 
00196    void* findSymbol(const std::string& symbolName)
00197    {
00198       return findSymbol(symbolName.c_str());
00199    }
00201 
00203 
00207    static void* findSymbolAndLibrary(const char* symbolName, LibraryNSPR& lib)
00208    {
00209       return PR_FindSymbolAndLibrary(symbolName, &lib.mLibrary);
00210    }
00211 
00212    static void* findSymbolAndLibrary(const std::string& symbolName,
00213                                      LibraryNSPR& lib)
00214    {
00215       return findSymbolAndLibrary(symbolName.c_str(), lib);
00216    }
00218 
00219 protected:
00223    void copy(const LibraryNSPR& lib)
00224    {
00225       this->mName    = lib.mName;
00226       this->mLibrary = lib.mLibrary;
00227    }
00228 
00229 private:
00230    std::string mName;      
00231    PRLibrary*  mLibrary;   
00232 };
00233 
00234 } // End of vpr namespace
00235 
00236 
00237 #endif /* _VPR_LIBRARY_NSPR_H_ */

Generated on Thu Jan 4 10:52:09 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1