aboutsummaryrefslogtreecommitdiff
path: root/packages/noncvs/windows/extra/Gem/dev/Gem/Dylib.h
blob: 4837c1c6ba2c8e1a5747ae887de1b2ba1ca54656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*-----------------------------------------------------------------
LOG
    GEM - Graphics Environment for Multimedia

	- registers a loader with Pd

    Copyright (c) 2010-2011 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at
    For information on usage and redistribution, and for a DISCLAIMER OF ALL
    WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution.

-----------------------------------------------------------------*/

#ifndef _INCLUDE__GEM_GEM_DYLIB_H_
#define _INCLUDE__GEM_GEM_DYLIB_H_

#include "Gem/Exception.h"


/* an opaque handle to the platform specific library handle */
class GemDylibHandle;
class CPPExtern;

class GEM_EXTERN GemDylib {
 private:
  GemDylibHandle*m_handle;

 public:
  GemDylib(const CPPExtern*obj, 
	   const std::string libname, 
	   const std::string extension=std::string("")
	   ) throw(GemException);
  GemDylib(const std::string libname, 
	   const std::string extension=std::string("")
	   ) throw(GemException);

  GemDylib(const GemDylib&);

  virtual ~GemDylib(void);

  typedef void (*function_t)(void);

  virtual GemDylib& operator=(const GemDylib&);

  // if void<procname>(void) exists in dylib, run it and return "true"
  // else return false;
  bool run(const std::string procname);

  // if <procname> exists in dylib, return it, else return NULL
  function_t proc(const std::string procname);

  public:
  /**
   * LoadLib(): convenience function that searches a library named <baselibname> and then runs <procname>()
   * if "extension" is NULL, a plaform-specific default is used
   * on success "true" is returned, else "false
   */
  static bool LoadLib(const std::string procname, 
		      const std::string baselibname, 
		      const std::string fileext=std::string(""));


  static const std::string getDefaultExtension(void);
};




#endif