Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / Service_Config_Stream_Test.cpp
blob9c490dff0551400701bd0b90e62a78591e13872d
1 // ============================================================================
2 //
3 // = LIBRARY
4 // tests
5 //
6 // = DESCRIPTION
7 // This test exercises ACE_Service_Config assembling a stream.
8 //
9 // = AUTHOR
10 // Steve Huston <shuston@riverace.com>
12 // ============================================================================
14 #include "test_config.h"
15 #include "ace/Log_Msg.h"
16 #include "ace/Module.h"
17 #include "ace/Service_Config.h"
18 #include "ace/Task.h"
21 * The Decrypter service is static and is configured into a stream
22 * dynamically.
24 * NOTE! This code is here, and it will trip up while being loaded. If
25 * "static Decrypter" is inserted into the .conf file's module list, this
26 * test will barf. This is arguably a weird test, but I don't know any
27 * reason it should not work; however, this behavior has never been tested
28 * and may not have ever worked... but if someone is feeling ambitious,
29 * please go ahead and make this work. I'm out of time and energy.
30 * -Steve Huston
32 class Static_Task : public ACE_Task<ACE_SYNCH>
34 public:
35 int open (void *) override
37 ACE_DEBUG ((LM_DEBUG,
38 ACE_TEXT ("opening %s\n"),
39 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
40 return 0;
43 int close (u_long) override
45 ACE_DEBUG ((LM_DEBUG,
46 ACE_TEXT ("closing %s\n"),
47 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
48 return 0;
51 int init (int, ACE_TCHAR *[]) override
53 ACE_DEBUG ((LM_DEBUG,
54 ACE_TEXT ("initializing %s\n"),
55 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
56 return 0;
59 int fini () override
61 ACE_DEBUG ((LM_DEBUG,
62 ACE_TEXT ("finalizing %s\n"),
63 this->name () ? this->name () : ACE_TEXT ("Static_Task")));
64 return 0;
68 class Decrypter : public ACE_Service_Object, public ACE_Module<ACE_SYNCH, ACE_System_Time_Policy>
70 public:
71 Decrypter ()
72 : ACE_Module<ACE_SYNCH, ACE_System_Time_Policy> (
73 ACE_TEXT ("Decrypter"),
74 &writer_, &reader_,
76 M_DELETE_NONE) // Tasks are members; don't delete
79 ACE_ALLOC_HOOK_DECLARE;
81 private:
82 Static_Task writer_;
83 Static_Task reader_;
86 ACE_FACTORY_DEFINE (ACE_Local_Service, Decrypter)
87 ACE_STATIC_SVC_DEFINE (Decrypter_Descriptor,
88 ACE_TEXT ("Decrypter"),
89 ACE_MODULE_T,
90 &ACE_SVC_NAME (Decrypter),
91 (ACE_Service_Type::DELETE_THIS |
92 ACE_Service_Type::DELETE_OBJ),
94 ACE_STATIC_SVC_REQUIRE (Decrypter_Descriptor)
96 ACE_ALLOC_HOOK_DEFINE(Decrypter);
98 int
99 run_main (int, ACE_TCHAR *argv[])
101 ACE_START_TEST (ACE_TEXT ("Service_Config_Stream_Test"));
103 ACE_STATIC_SVC_REGISTER (Decrypter);
105 // If you want to try the static module in the stream test (comments at
106 // the top of this file) it needs the -y in the argv list which enables
107 // static services. Otherwise it's not really needed. Same with the
108 // 'false' 4th arg to open() below - it allows static services.
109 ACE_TCHAR *_argv[5] = { argv[0],
110 const_cast<ACE_TCHAR*> (ACE_TEXT ("-d")),
111 const_cast<ACE_TCHAR*> (ACE_TEXT ("-y")),
112 const_cast<ACE_TCHAR*> (ACE_TEXT ("-f")),
113 const_cast<ACE_TCHAR*>
114 (ACE_TEXT ("Service_Config_Stream_Test.conf")) };
115 int status;
116 if ((status = ACE_Service_Config::open (5,
117 _argv,
118 ACE_DEFAULT_LOGGER_KEY,
119 false,
120 true /*ignore def svc.conf*/)) == -1)
121 ACE_ERROR ((LM_ERROR,
122 ACE_TEXT ("%p\n"),
123 ACE_TEXT ("open"),
124 1));
126 ACE_END_TEST;
127 return status;