summaryrefslogtreecommitdiff
path: root/tests/Framework_Component_DLL.cpp
blob: d4a141ff3d6a5b307238f7d89a2c5675fe168246 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// -*- C++ -*-
#include "Framework_Component_DLL.h"
#include "ace/Service_Config.h"
#include "ace/Service_Object.h"
#include "ace/Framework_Component_T.h"

ACE_RCSID (tests,
           Framework_Component_DLL,
           "$Id$")

ACE_DLL_UNLOAD_POLICY (Framework_Component_DLL, ACE_DLL_UNLOAD_POLICY_LAZY)

Simple_Service::Simple_Service (void)
{
  FRAMEWORK_COMPONENT_DLL_TRACE ("Simple_Service::Simple_Service");
}

Simple_Service::~Simple_Service (void)
{
  FRAMEWORK_COMPONENT_DLL_TRACE ("Simple_Service::~Simple_Service");
}

const ACE_TCHAR *
Simple_Service::name (void)
{
  FRAMEWORK_COMPONENT_DLL_TRACE ("Simple_Service::dll_name");
  return ACE_TEXT ("Simple_Service");
}

/***************************************************************************/

/// This is just a simple server that can be loaded via the ACE
/// Service Configuration framework and uses the singleton that
/// also lives in this library.
template <int which>
class Server_T : public ACE_Service_Object
{
public:
  int init (int, ACE_TCHAR *[])
  {
    FRAMEWORK_COMPONENT_DLL_TRACE ("Server_T::init");

    // Initialize the singleton
    FWCT_DLL_Singleton_Adapter_T <Simple_Service> *ss = SS_SINGLETON::instance ();

    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("Server_T::init() dll_name: %s\n"),
                ss->dll_name ()));
    return 0;
  }

  int fini (void)
  {
    FRAMEWORK_COMPONENT_DLL_TRACE ("Server_T::fini");
    return 0;
  }
};

typedef Server_T <1> Server_1;
FRAMEWORK_COMPONENT_DLL_SINGLETON_DECLARATION(Server_T<1>;)
ACE_FACTORY_DEFINE (Framework_Component_DLL, Server_1)

typedef Server_T <2> Server_2;
FRAMEWORK_COMPONENT_DLL_SINGLETON_DECLARATION(Server_T<2>;)
ACE_FACTORY_DEFINE (Framework_Component_DLL, Server_2)

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class Server_T<1>;
template class Server_T<2>;
template class FWCT_DLL_Singleton_Adapter_T<Simple_Service>;
template class ACE_DLL_Singleton_T< FWCT_DLL_Singleton_Adapter_T <Simple_Service>,
                                    ACE_SYNCH_MUTEX >;
template class ACE_Framework_Component_T<ACE_DLL_Singleton_T<FWCT_DLL_Singleton_Adapter_T<Simple_Service>,
                                         ACE_SYNCH_MUTEX> >;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate Server_T<1>
#pragma instantiate Server_T<2>
#pragma instantiate FWCT_DLL_Singleton_Adapter_T<Simple_Service>
#pragma instantiate ACE_DLL_Singleton_T< FWCT_DLL_Singleton_Adapter_T <Simple_Service>,
                                         ACE_SYNCH_MUTEX >
#pragma instantiate ACE_Framework_Component_T<ACE_DLL_Singleton_T<FWCT_DLL_Singleton_Adapter_T<Simple_Service>,
                                               ACE_SYNCH_MUTEX> >;
#elif defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)

template ACE_DLL_Singleton_T<FWCT_DLL_Singleton_Adapter_T <Simple_Service>,
                             ACE_SYNCH_MUTEX> *
  ACE_DLL_Singleton_T<FWCT_DLL_Singleton_Adapter_T <Simple_Service>,
                      ACE_SYNCH_MUTEX>::singleton_;

#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */