diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:11 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:11 +0000 |
commit | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (patch) | |
tree | da50d054f9c761c3f6a5923f6979e93306c56d68 /TAO/orbsvcs/tests/Notify/Structured_Multi_Filter/Structured_Consumer.cpp | |
parent | 0e555b9150d38e3b3473ba325b56db2642e6352b (diff) | |
download | ATCD-6b846cf03c0bcbd8c276cb0af61a181e5f98eaae.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/orbsvcs/tests/Notify/Structured_Multi_Filter/Structured_Consumer.cpp')
-rw-r--r-- | TAO/orbsvcs/tests/Notify/Structured_Multi_Filter/Structured_Consumer.cpp | 180 |
1 files changed, 0 insertions, 180 deletions
diff --git a/TAO/orbsvcs/tests/Notify/Structured_Multi_Filter/Structured_Consumer.cpp b/TAO/orbsvcs/tests/Notify/Structured_Multi_Filter/Structured_Consumer.cpp deleted file mode 100644 index eb633882bcc..00000000000 --- a/TAO/orbsvcs/tests/Notify/Structured_Multi_Filter/Structured_Consumer.cpp +++ /dev/null @@ -1,180 +0,0 @@ -// $Id$ - -#include "goC.h" -#include "Notify_Push_Consumer.h" -#include "Notify_Test_Client.h" - -#include "orbsvcs/CosNotifyChannelAdminC.h" -#include "orbsvcs/CosNotifyCommC.h" -#include "orbsvcs/CosNamingC.h" - -#include "tao/debug.h" - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_unistd.h" -#include "ace/OS_NS_strings.h" - -static const char* ior = "file://supplier.ior"; -static NS_FilterType consumerFilter = None; -static NS_FilterType supplierFilter = None; -static int numEvents = 90; // Must be multiple of 9 -static Notify_Push_Consumer* consumer = 0; - -static const char* GRAMMAR = "TCL"; - -class Consumer_Client : public Notify_Test_Client -{ -public: - virtual int parse_args (int argc, char* argv[]); -}; - -int -Consumer_Client::parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, "f:s:e:"); - int x; - - while ((x = get_opts ()) != -1) - switch (x) - { - case 'e': - numEvents = atoi (get_opts.optarg); - break; - - case 'f': - if (ACE_OS::strcasecmp ("OR", get_opts.optarg) == 0) - consumerFilter = OrOp; - else - consumerFilter = AndOp; - break; - - case 's': - if (ACE_OS::strcasecmp ("OR", get_opts.optarg) == 0) - supplierFilter = OrOp; - else - supplierFilter = AndOp; - break; - - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s " - "[-s <AND | OR>] -n <num events> " - "[-f <AND | OR>]" - "\n", - argv [0]), - -1); - } - - return 0; // successful parse -} - -static void -create_consumer (CosNotifyChannelAdmin::ConsumerAdmin_ptr admin, - CosNotifyChannelAdmin::EventChannel_ptr ec, - Notify_Test_Client* client - ACE_ENV_ARG_DECL) -{ - ACE_NEW_THROW_EX (consumer, - Notify_Push_Consumer ("Consumer", numEvents, consumerFilter, - supplierFilter, *client), - CORBA::NO_MEMORY ()); - - consumer->init (client->root_poa () ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - consumer->_connect (admin, ec ACE_ENV_ARG_PARAMETER); - ACE_CHECK; -} - -int main (int argc, char * argv[]) -{ - ACE_TRY_NEW_ENV - { - Consumer_Client client; - - int status = client.init (argc, argv ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - if (status != 0) - { - ACE_ERROR((LM_ERROR, "Error: Unable to init consumer.\n")); - return 1; - } - - CosNotifyChannelAdmin::EventChannel_var ec = - client.create_event_channel ("Struct_Multi_Filter", 1 ACE_ENV_ARG_PARAMETER); - - CosNotifyChannelAdmin::AdminID adminid = 0; - CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin = - ec->new_for_consumers ((consumerFilter == OrOp - ? CosNotifyChannelAdmin::OR_OP : CosNotifyChannelAdmin::AND_OP), - adminid ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_ASSERT(! CORBA::is_nil (consumer_admin.in ())); - - if (consumerFilter != None) - { - CosNotifyFilter::FilterFactory_var ffact = - ec->default_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - CosNotifyFilter::Filter_var filter = - ffact->create_filter (GRAMMAR ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (filter.in ())) - { - ACE_ERROR ((LM_ERROR, - " (%P|%t) Consumer unable to initialize filter.\n")); - return 1; - } - - CosNotifyFilter::ConstraintExpSeq constraint_list (1); - constraint_list.length (1); - - constraint_list[0].event_types.length (0); - constraint_list[0].constraint_expr = CORBA::string_dup ("type != 1"); - - filter->add_constraints (constraint_list ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - consumer_admin->add_filter (filter.in ()); - } - - CORBA::ORB_ptr orb = client.orb (); - - CORBA::Object_var object = - orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - sig_var sig = sig::_narrow (object.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_ASSERT(! CORBA::is_nil (sig.in ())); - - create_consumer (consumer_admin.in (), ec.in (), &client ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG((LM_DEBUG, "\nConsumer waiting for events...\n")); - - sig->go (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - client.ORB_run( ACE_ENV_SINGLE_ARG_PARAMETER ); - ACE_TRY_CHECK; - - ACE_DEBUG((LM_DEBUG, "\nConsumer done.\n")); - - sig->done(ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - return 0; - } - ACE_CATCH (CORBA::Exception, e) - { - ACE_PRINT_EXCEPTION (e, "\nError: Consumer:"); - } - ACE_ENDTRY; - - return 1; -} |