blob: 63224923e958886a11ef00361b8830f5e0029e04 (
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
69
70
71
72
73
|
// $Id$
// This program tests out how the various objects can be loaded
// dynamically and method calls made on them.
#include "Magazine.h"
#include "ace/DLL.h"
#include "ace/Auto_Ptr.h"
ACE_RCSID(DLL, test_dll, "$Id$")
typedef Magazine* (*Magazine_Creator) (void);
int
main (void)
{
ACE_DLL dll;
int retval = dll.open ("./" ACE_DLL_PREFIX "Today" ACE_DLL_SUFFIX);
if (retval != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"%s",
dll.error ()),
-1);
Magazine_Creator mc;
mc = (Magazine_Creator) dll.symbol ("create_magazine");
if (mc == 0)
ACE_ERROR_RETURN ((LM_ERROR,
dll.error ()),
-1);
Magazine *magazine = mc ();
magazine->title ();
delete magazine;
dll.close ();
// The other library is now loaded on demand.
retval = dll.open ("./" ACE_DLL_PREFIX "Newsweek" ACE_DLL_SUFFIX);
if (retval != 0)
ACE_ERROR_RETURN ((LM_ERROR,
"%s",
dll.error ()),
-1);
mc = (Magazine_Creator) dll.symbol ("create_magazine");
if (mc == 0)
ACE_ERROR_RETURN ((LM_ERROR,
dll.error ()),
-1);
magazine = mc ();
magazine->title ();
delete magazine;
dll.close ();
return 0;
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class auto_ptr <Magazine>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate auto_ptr <Magazine>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
|