summaryrefslogtreecommitdiff
path: root/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-03-21 02:06:07 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-03-21 02:06:07 +0000
commit8205230e2fdfff34ad827ca78a25b05c3ef2a398 (patch)
tree50e43748232eb77e00b9dd8bf10ba3d728f81655 /TAO/examples/Simulator/Event_Supplier/Event_Con.cpp
parentd79706b30ce5e66aea5effc0306f77975cb31032 (diff)
downloadATCD-8205230e2fdfff34ad827ca78a25b05c3ef2a398.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO/examples/Simulator/Event_Supplier/Event_Con.cpp')
-rw-r--r--TAO/examples/Simulator/Event_Supplier/Event_Con.cpp201
1 files changed, 105 insertions, 96 deletions
diff --git a/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp b/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp
index 5d53bbe9616..1c46bdc512f 100644
--- a/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp
+++ b/TAO/examples/Simulator/Event_Supplier/Event_Con.cpp
@@ -1,11 +1,18 @@
// $Id$
-//
+
// ============================================================================
//
-//
// = FILENAME
// Event_Con.cpp
//
+// = DESCRIPTION
+// This demo just tests the basic functionality of the Event Service
+// One Conumer which inherits from the Rtec Consumer. One Supplier
+// with an internal Rtec Consumer and one internal Rtec Supplier.
+// The internal Supplier is just a demo supplier because the
+// architecture expects an supplier which has inherited from the
+// Rtec Supplier.
+//
// = AUTHOR
// originally
// David Levine (levine@cs.wustl.edu) and
@@ -13,23 +20,13 @@
// modified
// Michael Kircher (mk1@cs.wustl.edu)
//
-// = DESCRIPTION
-// This demo just tests the basic functionality of the Event Service
-// One Conumer which inherits from the Rtec Consumer.
-// One Supplier with an internal Rtec Consumer and one internal Rtec Supplier.
-// The internal Supplier is just a demo supplier because the architecture
-// expects an supplier which has inherited from the Rtec Supplier.
-//
// ============================================================================
-
#include <limits.h>
-
#include "ace/Get_Opt.h"
#include "ace/Sched_Params.h"
#include "ace/Profile_Timer.h"
-
#include "tao/Timeprobe.h"
#include "orbsvcs/Event_Utilities.h"
#include "orbsvcs/Event_Service_Constants.h"
@@ -38,9 +35,10 @@
#include "Event_Con.h"
#include "NavWeapC.h"
-#define SOURCE_ID 1001
+static const int SOURCE_ID = 1001;
-static const char usage [] = "[-? |\n"
+static const char usage [] =
+"[-? |\n"
" [-c <consumers> [4]]\n"
" [-d directly connect all consumers/suppliers\n"
" [-j to collect jitter statistics]\n"
@@ -48,27 +46,29 @@ static const char usage [] = "[-? |\n"
" [-s <suppliers>, [1]]\n"
" [-t <timeout interval>, msec [250]]]";
-
-int received = 0;
-
-
+static int received = 0;
// ************************************************************
-Demo_Consumer::Demo_Consumer (){}
+Demo_Consumer::Demo_Consumer (void)
+{
+}
-int Demo_Consumer::open_consumer (RtecEventChannelAdmin::EventChannel_ptr ec,
- const char *my_name)
+int
+Demo_Consumer::open_consumer (RtecEventChannelAdmin::EventChannel_ptr ec,
+ const char *my_name)
{
TAO_TRY
{
- // Get a Scheduler
+ // Get a Scheduler.
- RtecScheduler::Scheduler_ptr server = ACE_Scheduler_Factory::server ();
+ RtecScheduler::Scheduler_ptr server =
+ ACE_Scheduler_Factory::server ();
- // Define Real-time information
+ // Define Real-time information.
rt_info_ = server->create (my_name, TAO_TRY_ENV);
+
server->set (rt_info_,
ORBSVCS_Time::zero,
ORBSVCS_Time::zero,
@@ -86,26 +86,30 @@ int Demo_Consumer::open_consumer (RtecEventChannelAdmin::EventChannel_ptr ec,
dependencies.insert_type (ACE_ES_EVENT_NOTIFICATION, rt_info_);
dependencies.insert_type (ACE_ES_EVENT_SHUTDOWN, rt_info_);
- // The channel administrator is the event channel we got from the invocation
- // of this routine
+ // The channel administrator is the event channel we got from
+ // the invocation of this routine.
this->channel_admin_ = ec;
- // = Connect as a consumer
+ // = Connect as a consumer.
- this->consumer_admin_ = channel_admin_->for_consumers (TAO_TRY_ENV);
+ this->consumer_admin_ =
+ channel_admin_->for_consumers (TAO_TRY_ENV);
TAO_CHECK_ENV;
- // Obtain a pointer to a push supplier
- // "suppliers" is inherited from a base class
+ // Obtain a pointer to a push supplier. "suppliers" is
+ // inherited from a base class.
- this->suppliers_ = consumer_admin_->obtain_push_supplier (TAO_TRY_ENV);
+ this->suppliers_ =
+ consumer_admin_->obtain_push_supplier (TAO_TRY_ENV);
TAO_CHECK_ENV;
// The _this function returns an object pointer. This is needed
- // because a consumer inherits from a Servant class that is no CORBA::Object.
+ // because a consumer inherits from a Servant class that is no
+ // CORBA::Object.
- RtecEventComm::PushConsumer_var objref = this->_this (TAO_TRY_ENV);
+ RtecEventComm::PushConsumer_var objref =
+ this->_this (TAO_TRY_ENV);
TAO_CHECK_ENV;
this->suppliers_->connect_push_consumer (objref.in (),
@@ -116,12 +120,14 @@ int Demo_Consumer::open_consumer (RtecEventChannelAdmin::EventChannel_ptr ec,
TAO_CATCH (RtecEventChannelAdmin::EventChannel::SUBSCRIPTION_ERROR, se)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "Demo_Consumer::open: subscribe failed.\n"), -1);
+ "Demo_Consumer::open: subscribe failed.\n"),
+ -1);
}
TAO_CATCHANY
{
ACE_ERROR_RETURN ((LM_ERROR,
- "Demo_Consumer::open: unexpected exception.\n"), -1);
+ "Demo_Consumer::open: unexpected exception.\n"),
+ -1);
}
TAO_ENDTRY;
@@ -131,7 +137,8 @@ int Demo_Consumer::open_consumer (RtecEventChannelAdmin::EventChannel_ptr ec,
void
Demo_Consumer::disconnect_push_consumer (CORBA::Environment &)
{
- ACE_DEBUG ((LM_DEBUG, "Consumer received disconnect from channel.\n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "Consumer received disconnect from channel.\n"));
}
void
@@ -198,7 +205,6 @@ Demo_Consumer::push (const RtecEventComm::EventSet &events,
void
Demo_Consumer::shutdown (void)
{
-
TAO_TRY
{
// Disconnect from the push supplier.
@@ -211,8 +217,6 @@ Demo_Consumer::shutdown (void)
TAO_ORB_Core_instance ()->orb ()->shutdown ();
TAO_CHECK_ENV;
-
-
}
TAO_CATCHANY
{
@@ -222,11 +226,6 @@ Demo_Consumer::shutdown (void)
TAO_ENDTRY;
}
-
-
-
-
-
// function get_options
static unsigned int
@@ -238,71 +237,74 @@ get_options (int argc, char *argv [])
while ((opt = get_opt ()) != EOF)
{
- switch (opt) {
- case '?':
- ACE_DEBUG ((LM_DEBUG,
- "Usage: %s %s\n",
- argv[0], usage));
- ACE_OS::exit (0);
- break;
- default:
- ACE_ERROR_RETURN ((LM_ERROR,
- "%s: unknown arg, -%c\n"
- "Usage: %s %s\n",
- argv[0], char(opt),
- argv[0], usage), 1);
- }
+ switch (opt)
+ {
+ case '?':
+ ACE_DEBUG ((LM_DEBUG,
+ "Usage: %s %s\n",
+ argv[0], usage));
+ ACE_OS::exit (0);
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%s: unknown arg, -%c\n"
+ "Usage: %s %s\n",
+ argv[0], char(opt),
+ argv[0], usage), 1);
+ }
}
if (argc != get_opt.optind)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "%s: too many arguments\n"
- "Usage: %s %s\n",
- argv[0], argv[0], usage), 1);
- }
-
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%s: too many arguments\n"
+ "Usage: %s %s\n",
+ argv[0],
+ argv[0],
+ usage),
+ 1);
return 0;
}
-
-// function main
+// function main.
int
main (int argc, char *argv [])
{
-
TAO_TRY
{
// Initialize ORB.
- CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "internet", TAO_TRY_ENV);
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "internet", TAO_TRY_ENV);
TAO_CHECK_ENV;
- CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA");
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+
if (CORBA::is_nil (poa_object.in ()))
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to initialize the POA.\n"),
- 1);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
- PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in (), TAO_TRY_ENV);
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in (), TAO_TRY_ENV);
TAO_CHECK_ENV;
- PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (TAO_TRY_ENV);
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager (TAO_TRY_ENV);
TAO_CHECK_ENV;
- CORBA::Object_var naming_obj = orb->resolve_initial_references ("NameService");
+ CORBA::Object_var naming_obj =
+ orb->resolve_initial_references ("NameService");
+
if (CORBA::is_nil (naming_obj.in ()))
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- " (%P|%t) Unable to initialize the POA.\n"),
- 1);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
CosNaming::NamingContext_var naming_context =
- CosNaming::NamingContext::_narrow (naming_obj.in (), TAO_TRY_ENV);
+ CosNaming::NamingContext::_narrow (naming_obj.in (),
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
ACE_Scheduler_Factory::use_config (naming_context.in ());
@@ -310,30 +312,38 @@ main (int argc, char *argv [])
if (get_options (argc, argv))
ACE_OS::exit (-1);
- // Get the Event Channel
+ // Get the Event Channel.
CosNaming::Name channel_name (1);
channel_name.length (1);
channel_name[0].id = CORBA::string_dup ("EventService");
- CORBA::Object_var ec_obj = naming_context->resolve (channel_name, TAO_TRY_ENV);
+ CORBA::Object_var ec_obj =
+ naming_context->resolve (channel_name,
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
-
RtecEventChannelAdmin::EventChannel_var ec =
RtecEventChannelAdmin::EventChannel::_narrow (ec_obj.in(), TAO_TRY_ENV);
TAO_CHECK_ENV;
if (ec.ptr() == 0)
- ACE_ERROR_RETURN ((LM_ERROR,"Not able to get the Event Service reference.\n"), -1);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Not able to get the Event Service reference.\n"),
+ -1);
// Create consumer.
Demo_Consumer *demo_consumer;
- ACE_NEW_RETURN (demo_consumer, Demo_Consumer (), -1);
+ ACE_NEW_RETURN (demo_consumer,
+ Demo_Consumer (),
+ -1);
- if (demo_consumer->open_consumer (ec.ptr (), "demo_consumer") == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "Someone was feeling introverted.\n"), -1);
+ if (demo_consumer->open_consumer (ec.ptr (),
+ "demo_consumer") == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Someone was feeling introverted.\n"),
+ -1);
poa_manager->activate (TAO_TRY_ENV);
TAO_CHECK_ENV;
@@ -341,8 +351,10 @@ main (int argc, char *argv [])
// Run the ORB
if (orb->run () == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "CORBA::ORB::run"), -1);
-
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "CORBA::ORB::run"),
+ -1);
TAO_CHECK_ENV;
delete demo_consumer;
@@ -350,8 +362,6 @@ main (int argc, char *argv [])
root_poa->destroy (CORBA::B_TRUE,
CORBA::B_TRUE,
TAO_TRY_ENV);
-
-
TAO_CHECK_ENV;
}
@@ -361,6 +371,5 @@ main (int argc, char *argv [])
}
TAO_ENDTRY;
-
return 0;
}