summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-99b10
-rw-r--r--TAO/ChangeLog-99c22
-rw-r--r--TAO/tests/Smart_Proxies/README44
-rw-r--r--TAO/tests/Smart_Proxies/Smart_Proxy_Impl.cpp49
-rw-r--r--TAO/tests/Smart_Proxies/client.cpp60
-rw-r--r--TAO/tests/Smart_Proxies/server.cpp99
-rw-r--r--TAO/tests/Smart_Proxies/test.idl17
-rw-r--r--ace/OS.i36
-rw-r--r--examples/Configuration/config_test.cpp416
9 files changed, 423 insertions, 330 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index 1689cec4f46..31310ca4509 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,4 +1,12 @@
-Mon Nov 22 07:50:48 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+Mon Nov 22 14:15:23 1999 Douglas C. Schmidt <schmidt@danzon.cs.wustl.edu>
+
+ * examples/Configuration/config_test.cpp: ACE-ified this example.
+
+ * ace/OS.i: Replaced all the uses of ACE_Time_Value private methods
+ within the overloaded global relational operator to use inline
+ methods. This change should work around bugs with MSVC++.
+ Thanks to Alok Gupta <alokg@ssind.stpn.soft.net> for reporting
+ this.
* ace/Service_Config.cpp (parse_args): Reverted the behavior
of parse_args() so that it doesn't return an error when it runs
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c
index fa6c510d773..c770d7c6e07 100644
--- a/TAO/ChangeLog-99c
+++ b/TAO/ChangeLog-99c
@@ -1,20 +1,22 @@
+Mon Nov 22 14:03:44 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * tests/Smart_Proxies: Revised the code to conform to the TAO
+ programming guidelines.
+
Mon Nov 22 14:04:14 1999 Jeff Parsons <parsons@cs.wustl.edu>
- * tao/Invocation.cpp:
- Added code to turn a user exception into an unknown
- exception on the client side for reliable oneways.
- Thanks to Carlos for clarifying the required behavior
- here.
+ * tao/Invocation.cpp: Added code to turn a user exception into an
+ unknown exception on the client side for reliable oneways.
+ Thanks to Carlos for clarifying the required behavior here.
Mon Nov 22 13:15:10 1999 Jeff Parsons <parsons@cs.wustl.edu>
* tao/Stub.cpp:
* TAO_IDL/be/be_visitor_operation/operation_cs.cpp:
- * TAO_IDL/be/be_visitor_operation/ami_cs.cpp:
- Added a 'const' to a variable that is cast from a
- declared constant in IDL, hopefully appeasing an
- older version of sunc++. Thanks to David for reporting
- this build error.
+ * TAO_IDL/be/be_visitor_operation/ami_cs.cpp: Added a 'const' to a
+ variable that is cast from a declared constant in IDL, hopefully
+ appeasing an older version of sunc++. Thanks to David for
+ reporting this build error.
Mon Nov 22 12:10:37 1999 Nanbor Wang <nanbor@cs.wustl.edu>
diff --git a/TAO/tests/Smart_Proxies/README b/TAO/tests/Smart_Proxies/README
new file mode 100644
index 00000000000..d7f9d8c8d86
--- /dev/null
+++ b/TAO/tests/Smart_Proxies/README
@@ -0,0 +1,44 @@
+$Id$
+
+Smart Proxies Overview
+----------------------
+
+Smart Proxies are a TAO extension that helps applications create
+user-defined proxies that can be used to add custom client-side
+processing and security to the default stub proxy.
+
+For details on how TAO implements Smart Proxies please see:
+
+www.cs.wustl.edu/~schmidt/ACE_wrappers/TAO/docs/Smart_Proxies.html
+
+Smart Proxy Example
+-------------------
+
+This director contains a simple example that demostrats how the TAO
+Smart Proxy feature can be used. In this example, just a single
+method has been "smartified" to illustrate how you just implement the
+methods you wish to customize since the rest will be taken care of the
+genearated Smart Proxy base class.
+
+All you need to define in the client application is a new factory that
+will produce the kind of proxy desired by the user. This factory must
+be provided by the user and must derive from the generated
+TAO_Default_Proxy_Factory class.
+
+For execution of the test:
+
+% Kirthika, please update this example to have a run_test.pl automated
+% perl script and update the following instructions.
+
+1) Generate the stubs:
+
+ ../../TAO_IDL/tao_idl -Ge 1 test.idl
+
+2) make
+
+3) ./server -o test.ior
+
+4) ./client
+
+Happy troubleshooting!
+
diff --git a/TAO/tests/Smart_Proxies/Smart_Proxy_Impl.cpp b/TAO/tests/Smart_Proxies/Smart_Proxy_Impl.cpp
index 8b1848b6288..48c5f67cdc9 100644
--- a/TAO/tests/Smart_Proxies/Smart_Proxy_Impl.cpp
+++ b/TAO/tests/Smart_Proxies/Smart_Proxy_Impl.cpp
@@ -2,47 +2,52 @@
#include "Smart_Proxy_Impl.h"
-smart_test_factory::smart_test_factory (void)
+Smart_Test_Factory::Smart_Test_Factory (void)
{
- ACE_DEBUG ((LM_DEBUG, "smart_test_factory\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Smart_Test_Factory\n"));
}
-test_ptr
-smart_test_factory::create_proxy (test_ptr proxy,
- CORBA::Environment &
- )
+Test_ptr
+Smart_Test_Factory::create_proxy (Test_ptr proxy,
+ CORBA::Environment &)
{
- ACE_DEBUG ((LM_DEBUG, "create_smart_proxy\n"));
- return (!CORBA::is_nil (proxy) ? new smart_test_proxy (proxy) : proxy);
+ ACE_DEBUG ((LM_DEBUG,
+ "create_smart_proxy\n"));
+ return CORBA::is_nil (proxy) == 0
+ // @@ Kirthika, please make sure to use the appropriate
+ // ACE_NEW_THROW macro here that checks for failures and raises
+ // an exception, etc.
+ ? new Smart_Test_Proxy (proxy)
+ : proxy;
}
-smart_test_proxy::smart_test_proxy (test_ptr proxy)
- : TAO_test_Smart_Proxy_Base (proxy)
+Smart_Test_Proxy::Smart_Test_Proxy (Test_ptr proxy)
+ : TAO_Test_Smart_Proxy_Base (proxy)
{
}
CORBA::Short
-smart_test_proxy::method (
- CORBA::Short boo,
- CORBA::Environment &ACE_TRY_ENV
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- test::Oops
- ))
+Smart_Test_Proxy::method (CORBA::Short boo,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Test::Oops))
{
- ACE_DEBUG ((LM_DEBUG, "Yahoo I am smart\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Yahoo, I am smart\n"));
CORBA::Short retval = 0;
ACE_TRY
{
- retval = TAO_test_Smart_Proxy_Base::method (boo, ACE_TRY_ENV);
+ retval = TAO_Test_Smart_Proxy_Base::method (boo,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
}
- ACE_CATCH (test::Oops, reason)
+ ACE_CATCH (Test::Oops, reason)
{
- ACE_PRINT_EXCEPTION (reason, "User Exception");
+ ACE_PRINT_EXCEPTION (reason,
+ "User Exception");
return -1;
}
ACE_ENDTRY;
diff --git a/TAO/tests/Smart_Proxies/client.cpp b/TAO/tests/Smart_Proxies/client.cpp
index c090c66cdd4..492eb1aa67f 100644
--- a/TAO/tests/Smart_Proxies/client.cpp
+++ b/TAO/tests/Smart_Proxies/client.cpp
@@ -1,5 +1,21 @@
// $Id$
+//========================================================================
+//
+// = LIBRARY
+// TAO/tests/Smart_Proxy
+//
+// = FILENAME
+// client.cpp
+//
+// = DESCRIPTION
+// This is the client program that tests TAO's Smart Proxy extension.
+//
+// = AUTHOR
+// Kirthika Parameswaran <kirthika@cs.wustl.edu>
+//
+//=========================================================================
+
#include "ace/Get_Opt.h"
#include "testC.h"
#include "Smart_Proxy_Impl.h"
@@ -39,40 +55,42 @@ main (int argc, char *argv[])
ACE_TRY_NEW_ENV
{
CORBA::ORB_var orb =
- CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV);
+ CORBA::ORB_init (argc,
+ argv,
+ "",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
if (parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var object =
- orb->string_to_object (ior, ACE_TRY_ENV);
+ orb->string_to_object (ior,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
- // For using the smart proxy:
- // Its necessary to allocate the user_defined smart factory on
- // the heap as the smart proxy generated classes take care of
- // destroying the object. This way it a win situation
- // for the application developer who doesnt have to
- // make sure to destoy it and also for the smart proxy
- // designer who now can manage the lifetime of the object
+ // To use the smart proxy it is necessary to allocate the
+ // user-defined smart factory on the heap as the smart proxy
+ // generated classes take care of destroying the object. This
+ // way it a win situation for the application developer who
+ // doesnt have to make sure to destoy it and also for the smart
+ // proxy designer who now can manage the lifetime of the object
// much surely.
- smart_test_factory *test_factory = 0;
+ Smart_Test_Factory *test_factory = 0;
ACE_NEW_RETURN (test_factory,
- smart_test_factory,
+ Smart_Test_Factory,
-1);
- test_var server =
- test::_narrow (object.in (), ACE_TRY_ENV);
+ Test_var server =
+ Test::_narrow (object.in (),
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
if (CORBA::is_nil (server.in ()))
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "Object reference <%s> is nil\n",
- ior),
- 1);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Object reference <%s> is nil\n",
+ ior),
+ 1);
server->method (0);
@@ -83,10 +101,10 @@ main (int argc, char *argv[])
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Client side exception:");
+ "Client-side exception:");
return 1;
}
ACE_ENDTRY;
- return 0;
+ return 0;
}
diff --git a/TAO/tests/Smart_Proxies/server.cpp b/TAO/tests/Smart_Proxies/server.cpp
index 0daf77bc727..ddc0c2a2a16 100644
--- a/TAO/tests/Smart_Proxies/server.cpp
+++ b/TAO/tests/Smart_Proxies/server.cpp
@@ -9,8 +9,7 @@
// server.cpp
//
// = DESCRIPTION
-// This is the server program for the test which tests the smart
-// proxy feature of TAO.
+// This is the server program that tests TAO's Smart Proxy extension.
//
// = AUTHOR
// Kirthika Parameswaran <kirthika@cs.wustl.edu>
@@ -22,62 +21,54 @@
ACE_RCSID(Smart_Proxy, server, "$Id$")
-
// The servant
-class test_i : public POA_test
+class Test_i : public POA_Test
{
public:
-
- test_i (CORBA::ORB_ptr orb);
+ Test_i (CORBA::ORB_ptr orb);
- CORBA::Short method (
- CORBA::Short boo,
- CORBA::Environment &ACE_TRY_ENV
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- test::Oops
- ));
-
- void shutdown (
- CORBA::Environment &ACE_TRY_ENV
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException
- ));
+ CORBA::Short method (CORBA::Short boo,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Test::Oops));
+
+ void shutdown (CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException));
private:
CORBA::ORB_var orb_;
};
-test_i::test_i (CORBA::ORB_ptr orb)
+Test_i::Test_i (CORBA::ORB_ptr orb)
: orb_ (CORBA::ORB::_duplicate (orb))
{
}
CORBA::Short
-test_i :: method (CORBA::Short boo,
+Test_i :: method (CORBA::Short boo,
CORBA::Environment &ACE_TRY_ENV)
- ACE_THROW_SPEC ((CORBA::SystemException, test::Oops))
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ Test::Oops))
{
ACE_DEBUG ((LM_DEBUG,
- ASYS_TEXT ("test_i::method () invoked\n")));
+ ASYS_TEXT ("Test_i::method () invoked\n")));
if (boo == 5)
- ACE_THROW_RETURN (test::Oops ("Invalid boo\n"), -1);
+ ACE_THROW_RETURN (Test::Oops ("Invalid boo\n"),
+ -1);
return 0;
}
void
-test_i::shutdown (CORBA::Environment &)
+Test_i::shutdown (CORBA::Environment &)
ACE_THROW_SPEC ((CORBA::SystemException))
{
this->orb_->shutdown ();
}
-const char *ior_output_file = 0;
+static const char *ior_output_file = 0;
int
parse_args (int argc, char *argv[])
@@ -111,20 +102,24 @@ main (int argc, char *argv[])
ACE_TRY
{
-
if (parse_args (argc, argv) != 0)
return 1;
- CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "", ACE_TRY_ENV);
+ CORBA::ORB_var orb = CORBA::ORB_init (argc,
+ argv,
+ "",
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
- test_i servant (orb.in ());
+ Test_i servant (orb.in ());
// Obtain RootPOA.
- CORBA::Object_var object = orb->resolve_initial_references ("RootPOA",
- ACE_TRY_ENV);
+ CORBA::Object_var object =
+ orb->resolve_initial_references ("RootPOA",
+ ACE_TRY_ENV);
- PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in (),
- ACE_TRY_ENV);
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (object.in (),
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
@@ -133,21 +128,28 @@ main (int argc, char *argv[])
root_poa->the_POAManager (ACE_TRY_ENV);
ACE_TRY_CHECK;
- test_var test_object = servant._this (ACE_TRY_ENV);
+ test_var test_object =
+ servant._this (ACE_TRY_ENV);
- CORBA::String_var ior = orb->object_to_string (test_object.in (),
- ACE_TRY_ENV);
+ CORBA::String_var ior =
+ orb->object_to_string (test_object.in (),
+ ACE_TRY_ENV);
// If the ior_output_file exists, output the ior to it
if (ior_output_file != 0)
{
- FILE *output_file = ACE_OS::fopen (ior_output_file, "w");
+ FILE *output_file =
+ ACE_OS::fopen (ior_output_file, "w");
+
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
1);
- ACE_OS::fprintf (output_file, "%s", ior.in ());
+
+ ACE_OS::fprintf (output_file,
+ "%s",
+ ior.in ());
ACE_OS::fclose (output_file);
}
@@ -155,19 +157,26 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
if (orb->run () == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "orb->run"), -1);
- ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "orb->run"),
+ -1);
+ ACE_DEBUG ((LM_DEBUG,
+ "event loop finished\n"));
- root_poa->destroy (1, 1, ACE_TRY_ENV);
+ root_poa->destroy (1,
+ 1,
+ ACE_TRY_ENV);
ACE_TRY_CHECK;
}
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception in setting up server");
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception in setting up server");
ACE_ASSERT (0);
}
ACE_ENDTRY;
-return 0;
+ return 0;
}
diff --git a/TAO/tests/Smart_Proxies/test.idl b/TAO/tests/Smart_Proxies/test.idl
index a42289bfb66..a9d3b46c7fc 100644
--- a/TAO/tests/Smart_Proxies/test.idl
+++ b/TAO/tests/Smart_Proxies/test.idl
@@ -1,10 +1,19 @@
// $Id$
-interface test
+interface Test
{
- exception Oops {string reason;};
+ // = TITLE
+ // @@ Kirthika, please fill in here.
+ //
+ // = DESCRIPTION
+ // @@ Kirthika, please fill in here.
- short method (in short boo) raises (Oops);
+ exception Oops
+ {
+ string reason;
+ };
- oneway void shutdown ();
+ short method (in short boo) raises (Oops);
+
+ oneway void shutdown ();
};
diff --git a/ace/OS.i b/ace/OS.i
index 759ec7e1660..7419c2294e2 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -297,10 +297,10 @@ operator > (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
{
ACE_TRACE ("operator >");
- if (tv1.tv_.tv_sec > tv2.tv_.tv_sec)
+ if (tv1.sec () > tv2.sec ())
return 1;
- else if (tv1.tv_.tv_sec == tv2.tv_.tv_sec
- && tv1.tv_.tv_usec > tv2.tv_.tv_usec)
+ else if (tv1.sec () == tv2.sec ()
+ && tv1.usec () > tv2.usec ())
return 1;
else
return 0;
@@ -313,10 +313,10 @@ operator >= (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
{
ACE_TRACE ("operator >=");
- if (tv1.tv_.tv_sec > tv2.tv_.tv_sec)
+ if (tv1.sec () > tv2.sec ())
return 1;
- else if (tv1.tv_.tv_sec == tv2.tv_.tv_sec
- && tv1.tv_.tv_usec >= tv2.tv_.tv_usec)
+ else if (tv1.sec () == tv2.sec ()
+ && tv1.usec () >= tv2.usec ())
return 1;
else
return 0;
@@ -330,11 +330,11 @@ ACE_Time_Value::operator timespec_t () const
ACE_TRACE ("ACE_Time_Value::operator timespec_t");
timespec_t tv;
#if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS)
- tv.tv_sec = this->tv_.tv_sec;
+ tv.tv_sec = this->sec ();
// Convert microseconds into nanoseconds.
tv.tv_nsec = this->tv_.tv_usec * 1000;
#else
- tv.ts_sec = this->tv_.tv_sec;
+ tv.ts_sec = this->sec ();
// Convert microseconds into nanoseconds.
tv.ts_nsec = this->tv_.tv_usec * 1000;
#endif /* ACE_HAS_BROKEN_TIMESPEC_MEMBERS */
@@ -444,8 +444,8 @@ operator == (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
{
// ACE_TRACE ("operator ==");
- return tv1.tv_.tv_sec == tv2.tv_.tv_sec
- && tv1.tv_.tv_usec == tv2.tv_.tv_usec;
+ return tv1.sec () == tv2.sec ()
+ && tv1.usec () == tv2.usec ();
}
// True if tv1 != tv2.
@@ -464,8 +464,8 @@ ACE_INLINE void
ACE_Time_Value::operator+= (const ACE_Time_Value &tv)
{
ACE_TRACE ("ACE_Time_Value::operator+=");
- this->tv_.tv_sec += tv.tv_.tv_sec;
- this->tv_.tv_usec += tv.tv_.tv_usec;
+ this->sec (this->sec () + tv.sec ());
+ this->usec (this->usec () + tv.usec ());
this->normalize ();
}
@@ -475,8 +475,8 @@ ACE_INLINE void
ACE_Time_Value::operator-= (const ACE_Time_Value &tv)
{
ACE_TRACE ("ACE_Time_Value::operator-=");
- this->tv_.tv_sec -= tv.tv_.tv_sec;
- this->tv_.tv_usec -= tv.tv_.tv_usec;
+ this->sec (this->sec () - tv.sec ());
+ this->usec (this->usec () - tv.usec ());
this->normalize ();
}
@@ -487,8 +487,8 @@ operator + (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
{
ACE_TRACE ("operator +");
- ACE_Time_Value sum (tv1.tv_.tv_sec + tv2.tv_.tv_sec,
- tv1.tv_.tv_usec + tv2.tv_.tv_usec);
+ ACE_Time_Value sum (tv1.sec () + tv2.sec (),
+ tv1.usec () + tv2.usec ());
sum.normalize ();
return sum;
@@ -501,8 +501,8 @@ operator - (const ACE_Time_Value &tv1,
const ACE_Time_Value &tv2)
{
ACE_TRACE ("operator -");
- ACE_Time_Value delta (tv1.tv_.tv_sec - tv2.tv_.tv_sec,
- tv1.tv_.tv_usec - tv2.tv_.tv_usec);
+ ACE_Time_Value delta (tv1.sec () - tv2.sec (),
+ tv1.usec () - tv2.usec ());
delta.normalize ();
return delta;
}
diff --git a/examples/Configuration/config_test.cpp b/examples/Configuration/config_test.cpp
index 9a9eb1450d8..38fa3e9e5b8 100644
--- a/examples/Configuration/config_test.cpp
+++ b/examples/Configuration/config_test.cpp
@@ -3,334 +3,332 @@
#include "ace/Configuration.h"
int
-test (ACE_Configuration* config)
+test (ACE_Configuration *config)
{
- ACE_Configuration_Section_Key root = config->root_section ();
+ ACE_Configuration_Section_Key root =
+ config->root_section ();
- // add a section
+ // Add a section.
ACE_Configuration_Section_Key testsection;
- if (config->open_section (root, "test", 1, testsection))
- {
- return -2;
- }
- // Set some values
- if (config->set_string_value (testsection, "stvalue", "stvaluetest"))
- {
- return -3;
- }
+ if (config->open_section (root,
+ "test",
+ 1,
+ testsection))
+ return -2;
- if (config->remove_value (testsection, "stvalue"))
- {
- return -4;
- }
- if (config->set_string_value (testsection, "stvalue", "stvaluetest"))
- {
- return -3;
- }
+ // Set some values.
+ else if (config->set_string_value (testsection,
+ "stvalue",
+ "stvaluetest"))
+ return -3;
+
+ else if (config->remove_value (testsection,
+ "stvalue"))
+ return -4;
+
+ else if (config->set_string_value (testsection,
+ "stvalue",
+ "stvaluetest"))
+ return -3;
+
+ else if (config->set_integer_value (testsection,
+ "intvalue",
+ 42))
+ return -4;
+
+ u_char data[80];
- if (config->set_integer_value (testsection, "intvalue", 42))
- {
- return -4;
- }
- unsigned char data[80];
for(int i = 0; i < 80; i++)
- {
- data[i] = i + 128;
- }
+ data[i] = i + 128;
- if (config->set_binary_value (testsection, "binvalue", data, 80))
- {
- return -5;
- }
+ if (config->set_binary_value (testsection,
+ "binvalue",
+ data,
+ 80))
+ return -5;
// Get the values and compare
ACE_TString stvalue;
- if (config->get_string_value (testsection, "stvalue", stvalue))
- {
- return -6;
- }
- if (stvalue != "stvaluetest")
- {
- return -7;
- }
- unsigned int intvalue;
- if (config->get_integer_value (testsection, "intvalue", intvalue))
- {
- return -8;
- }
- if (intvalue != 42)
- {
- return -9;
- }
+ if (config->get_string_value (testsection,
+ "stvalue",
+ stvalue))
+ return -6;
+ else if (stvalue != "stvaluetest")
+ return -7;
+
+ u_int intvalue;
+
+ if (config->get_integer_value (testsection,
+ "intvalue",
+ intvalue))
+ return -8;
+ else if (intvalue != 42)
+ return -9;
+
+ u_char *data_out = 0;
+ u_int length = 0;
- unsigned char* data_out = 0;
- unsigned int length = 0;
if (config->get_binary_value (testsection,
"binvalue",
(void*&) data_out,
length))
- {
- return -10;
- }
+ return -10;
+
// compare em
for(int j = 0; j < 80; j++)
- {
- if (data_out[j] != data[j])
- {
- return -11;
- }
- }
+ if (data_out[j] != data[j])
+ return -11;
+
delete data_out;
- // test iteration
+ // Test iteration.
ACE_TString name;
ACE_Configuration::VALUETYPE type;
- unsigned int index = 0;
+ u_int index = 0;
int count = 0;
- while(!config->enumerate_values (testsection, index, name, type))
+
+ while (!config->enumerate_values (testsection,
+ index,
+ name,
+ type))
{
if (name == "stvalue")
{
if (type != ACE_Configuration::STRING)
- {
- return -12;
- }
+ return -12;
count++;
}
else if (name == "intvalue")
{
if (type != ACE_Configuration::INTEGER)
- {
- return -13;
- }
+ return -13;
count++;
}
else if (name == "binvalue")
{
if (type != ACE_Configuration::BINARY)
- {
- return -14;
- }
+ return -14;
count++;
}
index++;
}
- // Make sure we got three values
+
+ // Make sure we got three values.
if (index != 3 || count !=3)
- {
- return -15;
- }
- // Add some subsections
- ACE_Configuration_Section_Key test2, test3, test4;
- if (config->open_section (testsection, "test2", 1, test2))
- {
- return -16;
- }
- if (config->open_section (testsection, "test3", 1, test3))
- {
- return -17;
- }
- if (config->open_section (testsection, "test4", 1, test4))
- {
- return -18;
- }
+ return -15;
+
+ // Add some subsections.
+ ACE_Configuration_Section_Key test2;
+ ACE_Configuration_Section_Key test3;
+ ACE_Configuration_Section_Key test4;
+
+ if (config->open_section (testsection,
+ "test2",
+ 1,
+ test2))
+ return -16;
+ else if (config->open_section (testsection,
+ "test3",
+ 1,
+ test3))
+ return -17;
+ else if (config->open_section (testsection,
+ "test4",
+ 1,
+ test4))
+ return -18;
- // test enumerate sections
+ // Test enumerate sections.
index = 0;
count = 0;
- while(!config->enumerate_sections (testsection, index, name))
+ while (!config->enumerate_sections (testsection,
+ index,
+ name))
{
if (name == "test2")
- {
- count++;
- }
+ count++;
else if (name == "test3")
- {
- count++;
- }
+ count++;
else if (name == "test4")
- {
- count++;
- }
+ count++;
index++;
}
- if (index !=3 || count !=3)
- {
- return -19;
- }
+
+ if (index != 3 || count != 3)
+ return -19;
// Remove a subsection
- if (config->remove_section (testsection, "test2", 0))
- {
- return -20;
- }
+ if (config->remove_section (testsection,
+ "test2",
+ 0))
+ return -20;
// Try to remove it again
- if (!config->remove_section (testsection, "test2", 0))
- {
- return -21;
- }
- // try to remove the testsection root, it should fail since it still
+ if (!config->remove_section (testsection,
+ "test2",
+ 0))
+ return -21;
+
+ // Try to remove the testsection root, it should fail since it still
// has subkeys
- if (!config->remove_section (root, "test", 0))
- {
- return -22;
- }
+ if (!config->remove_section (root,
+ "test",
+ 0))
+ return -22;
// Test find section
ACE_Configuration_Section_Key result;
- if (config->open_section (root, "test", 0, result))
- {
- return -23;
- }
- // now test the recursive remove
- if (config->remove_section (root, "test", 1))
- {
- return -24;
- }
+ if (config->open_section (root,
+ "test",
+ 0,
+ result))
+ return -23;
+
+ // Now test the recursive remove.
+ if (config->remove_section (root,
+ "test",
+ 1))
+ return -24;
// Make sure its not there
- if (!config->open_section (root, "test", 0, testsection))
- {
- return -25;
- }
+ if (!config->open_section (root,
+ "test",
+ 0,
+ testsection))
+ return -25;
return 0;
}
int
-test_io (ACE_Configuration* config)
+test_io (ACE_Configuration *config)
{
// Populate with some data
- ACE_Configuration_Section_Key root = config->root_section ();
+ ACE_Configuration_Section_Key root =
+ config->root_section ();
ACE_Configuration_Section_Key test;
- if (config->open_section(root, "test", 1, test))
- {
- return -1;
- }
+
+ if (config->open_section(root,
+ "test",
+ 1,
+ test))
+ return -1;
+
ACE_TString value ("string value");
- if (config->set_string_value (test, "stvalue", value))
- {
- return -2;
- }
- if (config->set_string_value (test, "stvalue1", value))
- {
- return -3;
- }
- if (config->set_integer_value (test, "intvalue", 42))
- {
- return -4;
- }
+
+ if (config->set_string_value (test,
+ "stvalue",
+ value))
+ return -2;
+ else if (config->set_string_value (test,
+ "stvalue1",
+ value))
+ return -3;
+ else if (config->set_integer_value (test,
+ "intvalue",
+ 42))
+ return -4;
ACE_Configuration_Section_Key test2;
- if (config->open_section (test, "test2", 1, test2))
- {
- return -5;
- }
- if (config->set_string_value (test2, "2stvalue", value))
- {
- return -6;
- }
- if (config->set_string_value (test2, "2stvalue1", value))
- {
- return -7;
- }
- if (config->set_integer_value (test2, "2intvalue", 42))
- {
- return -8;
- }
+
+ if (config->open_section (test,
+ "test2",
+ 1,
+ test2))
+ return -5;
+ else if (config->set_string_value (test2,
+ "2stvalue",
+ value))
+ return -6;
+ else if (config->set_string_value (test2,
+ "2stvalue1",
+ value))
+ return -7;
+ else if (config->set_integer_value (test2,
+ "2intvalue",
+ 42))
+ return -8;
+
// Export it to a file
- if(config->export_config("config.ini"))
- {
+ if(config->export_config ("config.ini"))
return -9;
- }
// reimport
- if(config->import_config("config.ini"))
- {
+
+ if (config->import_config ("config.ini"))
return -10;
- }
+
return 0;
}
int
main (int, char *[])
{
-#if defined(WIN32)
- // test win32 registry implementation
+#if defined (ACE_WIN32)
+ // test win32 registry implementation.
HKEY root =
ACE_Configuration_Win32Registry::resolve_key (HKEY_LOCAL_MACHINE,
"Software\\ACE\\test");
if (!root)
- {
- return -1;
- }
+ return -1;
+
ACE_Configuration_Win32Registry RegConfig (root);
{
int result = test (&RegConfig);
if (result)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "Win32 registry test failed (%d)\n", result),
- -1);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Win32 registry test failed (%d)\n", result),
+ -1);
}
-#endif
+#endif /* ACE_WIN32 */
// Test Heap version
ACE_Configuration_Heap heap_config;
+
if (heap_config.open ())
- {
- return 0;
- }
+ return 0;
{
int result = test (&heap_config);
if (result)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "Heap Configuration test failed (%d)\n", result),
- -1);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Heap Configuration test failed (%d)\n",
+ result),
+ -1);
}
// Test persistent heap version
- unlink ("test.reg");
+ ACE_OS::unlink ("test.reg");
ACE_Configuration_Heap pers_config;
+
if (pers_config.open ("test.reg"))
- {
- return 0;
- }
+ return 0;
{
int result = test (&pers_config);
if (result)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "Persistent Heap Configuration test failed (%d)\n",
- result),
- -1);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Persistent Heap Configuration test failed (%d)\n",
+ result),
+ -1);
}
// Test file i/o using a transient heap
ACE_Configuration_Heap io_config;
if (io_config.open ())
- {
- return -2;
- }
+ return -2;
int result = test_io (&io_config);
if (result)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "IO Test Failed (%d)\n", result),
- -3);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "IO Test Failed (%d)\n",
+ result),
+ -3);
- ACE_DEBUG ((LM_DEBUG, "Test passed\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Test passed\n"));
return 0;
}