Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / tests / DLL_Test_Impl.cpp
blob65319575d1238c3f29c727734bf2580710fd65a1
2 //=============================================================================
3 /**
4 * @file DLL_Test_Impl.cpp
6 * This test illustrates the use of <ACE_DLL> wrapper class.
8 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
9 */
10 //=============================================================================
13 #include "DLL_Test_Impl.h"
14 #include "ace/ACE.h"
15 #include "ace/OS_Errno.h"
16 #include "ace/svc_export.h"
17 #include "ace/OS_NS_string.h"
19 Hello_Impl::Hello_Impl (void)
21 ACE_DEBUG ((LM_DEBUG, "Hello_Impl::Hello_Impl\n"));
24 Hello_Impl::~Hello_Impl (void)
26 ACE_DEBUG ((LM_DEBUG, "Hello_Impl::~Hello_Impl\n"));
29 void
30 Hello_Impl::say_next (void)
32 ACE_DEBUG ((LM_DEBUG,
33 ACE_TEXT ("How are you?\n")));
36 ACE_TCHAR *
37 Hello_Impl::new_info (void)
39 return ACE::strnew (ACE_TEXT ("Hello_Impl::new_info() allocated by ACE::strnew()"));
42 ACE_TCHAR *
43 Hello_Impl::malloc_info (void)
45 return ACE_OS::strdup (ACE_TEXT ("Hello_Impl::new_info() allocated by ACE_OS::malloc()"));
48 void *
49 Hello_Impl::operator new (size_t bytes)
51 ACE_DEBUG ((LM_INFO, "Hello_Impl::new\n"));
52 return ::new char[bytes];
55 #if defined (ACE_HAS_NEW_NOTHROW)
56 /// Overloaded new operator, nothrow_t variant.
57 void *
58 Hello_Impl::operator new (size_t bytes, const ACE_nothrow_t &nt)
60 ACE_DEBUG ((LM_INFO, "Hello_Impl::new\n"));
61 return ::new (nt) char[bytes];
64 #if !defined (ACE_LACKS_PLACEMENT_OPERATOR_DELETE)
65 void
66 Hello_Impl::operator delete (void *ptr, const ACE_nothrow_t&) throw ()
68 ACE_DEBUG ((LM_INFO, "Hello_Impl::delete\n"));
69 ::delete [] static_cast<char *> (ptr);
71 #endif /* ACE_LACKS_PLACEMENT_OPERATOR_DELETE */
73 #endif /* ACE_HAS_NEW_NOTHROW */
75 void
76 Hello_Impl::operator delete (void *ptr)
78 ACE_DEBUG ((LM_INFO, "Hello_Impl::delete\n"));
79 ::delete [] static_cast<char *> (ptr);
82 extern "C" ACE_Svc_Export Hello *
83 get_hello (void)
85 Hello *hello = 0;
87 ACE_NEW_RETURN (hello,
88 Hello_Impl,
89 0);
91 return hello;
94 class Static_Constructor_Test
96 public:
97 Static_Constructor_Test (void)
99 ACE_DEBUG ((LM_DEBUG,
100 "Static_Constructor_Test::Static_Constructor_Test\n"));
102 ~Static_Constructor_Test (void)
104 ACE_DEBUG ((LM_DEBUG,
105 "Static_Constructor_Test::~Static_Constructor_Test\n"));
109 static Static_Constructor_Test the_instance;
111 // --------------------------------------------------------
113 Child::Child (void)
117 Child::~Child (void)
121 void
122 Child::test (void)
124 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("child called\n")));
127 // --------------------------------------------------------
130 // Test dynamic cast
131 extern "C" ACE_Svc_Export int
132 dynamic_cast_test (Parent *target)
134 Child *c = 0;
135 c = dynamic_cast<Child*> (target);
136 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("dynamic_cast_test: parent %@; child %@\n"),
137 target, c));
138 return target == c ? 0 : -1;