summaryrefslogtreecommitdiff
path: root/TAO/examples/Callback_Quoter
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/examples/Callback_Quoter')
-rw-r--r--TAO/examples/Callback_Quoter/Consumer.idl40
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_Handler.cpp25
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_Handler.h18
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_Input_Handler.cpp37
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_Input_Handler.h43
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_Signal_Handler.cpp15
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_Signal_Handler.h12
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_i.cpp13
-rw-r--r--TAO/examples/Callback_Quoter/Consumer_i.h11
-rw-r--r--TAO/examples/Callback_Quoter/Notifier.idl20
-rw-r--r--TAO/examples/Callback_Quoter/Notifier_Input_Handler.cpp45
-rw-r--r--TAO/examples/Callback_Quoter/Notifier_Input_Handler.h18
-rw-r--r--TAO/examples/Callback_Quoter/Notifier_i.cpp24
-rw-r--r--TAO/examples/Callback_Quoter/Notifier_i.h32
-rw-r--r--TAO/examples/Callback_Quoter/README11
-rw-r--r--TAO/examples/Callback_Quoter/Supplier_Timer_Handler.cpp17
-rw-r--r--TAO/examples/Callback_Quoter/Supplier_Timer_Handler.h11
-rw-r--r--TAO/examples/Callback_Quoter/Supplier_i.cpp27
-rw-r--r--TAO/examples/Callback_Quoter/Supplier_i.h14
-rw-r--r--TAO/examples/Callback_Quoter/consumer.cpp1
-rw-r--r--TAO/examples/Callback_Quoter/notifier.cpp4
-rw-r--r--TAO/examples/Callback_Quoter/supplier.cpp1
22 files changed, 128 insertions, 311 deletions
diff --git a/TAO/examples/Callback_Quoter/Consumer.idl b/TAO/examples/Callback_Quoter/Consumer.idl
index 07bc8ba9afe..7223f23c9fd 100644
--- a/TAO/examples/Callback_Quoter/Consumer.idl
+++ b/TAO/examples/Callback_Quoter/Consumer.idl
@@ -2,56 +2,44 @@
#if !defined (_CONSUMER_IDL)
#define _CONSUMER_IDL
+/// This module contains the data structure defined to store
+/// information and the consumer interface.
module Callback_Quoter
{
- // = TITLE
- // This module contains the data structure defined to store
- // information and the consumer interface.
-
+ // Requested stock does not exist.
exception Invalid_Stock
{
- // = TITLE
- // Requested stock does not exist.
-
+ /// The message which declares the reason for this exception.
string reason;
- // The message which declares the reason for this exception.
-
};
+ /// Requested object does not exist.
exception Invalid_Handle
{
- // = TITLE
- // Requested object does not exist.
-
+ /// The actual reason which caused the exception.
string reason;
- // The actual reason which caused the exception.
-
};
+ /// The information passed by the Notifier to the consumer.
struct Info
{
- // = TITLE
- // The information passed by the Notifier to the consumer.
-
+ /// This is the name of the stock about whom the consumer
+ /// is seeking information.
string stock_name;
- // This is the name of the stock about whom the consumer
- // is seeking information.
+ /// This is the market price of the stock.
long value;
- // This is the market price of the stock.
};
+ /// The Consumer interface which is utilized by the Notifier
+ /// to pass information to the consumer.
interface Consumer
{
- // = TITLE
- // The Consumer interface which is utilized by the Notifier
- // to pass information to the consumer.
-
+ /// Notifier sends data to the consumer.
void push (in Callback_Quoter::Info data);
- // Notifier sends data to the consumer.
+ /// the process shuts down.
void shutdown ();
- // the process shuts down.
};
};
diff --git a/TAO/examples/Callback_Quoter/Consumer_Handler.cpp b/TAO/examples/Callback_Quoter/Consumer_Handler.cpp
index 6d93850e49f..96809c6d364 100644
--- a/TAO/examples/Callback_Quoter/Consumer_Handler.cpp
+++ b/TAO/examples/Callback_Quoter/Consumer_Handler.cpp
@@ -23,7 +23,7 @@
#include "ace/Event_Handler.h"
#include "ace/OS_NS_fcntl.h"
-Consumer_Handler::Consumer_Handler (void)
+Consumer_Handler::Consumer_Handler ()
: stock_name_ ("Unknown"),
threshold_value_ (0),
server_ (),
@@ -34,13 +34,11 @@ Consumer_Handler::Consumer_Handler (void)
use_naming_service_ (1),
interactive_ (1)
{
-
}
-Consumer_Handler::~Consumer_Handler (void)
+Consumer_Handler::~Consumer_Handler ()
{
// Make sure to cleanup the STDIN handler.
-
if (this->interactive_ == 1)
{
if (ACE_Event_Handler::remove_stdin_handler
@@ -53,7 +51,6 @@ Consumer_Handler::~Consumer_Handler (void)
}
// Reads the Server factory IOR from a file.
-
int
Consumer_Handler::read_ior (ACE_TCHAR *filename)
{
@@ -83,9 +80,8 @@ Consumer_Handler::read_ior (ACE_TCHAR *filename)
}
// Parses the command line arguments and returns an error status.
-
int
-Consumer_Handler::parse_args (void)
+Consumer_Handler::parse_args ()
{
ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("a:t:d:f:xk:xs"));
int c;
@@ -124,7 +120,6 @@ Consumer_Handler::parse_args (void)
this->threshold_value_ = ACE_OS::atoi (get_opts.opt_arg ());
break;
-
case 'x':
this->shutdown_ = 1;
break;
@@ -149,10 +144,9 @@ Consumer_Handler::parse_args (void)
return 0;
}
-// this method uses the naming service to obtain the server object refernce.
-
+// This method uses the naming service to obtain the server object reference.
int
-Consumer_Handler::via_naming_service (void)
+Consumer_Handler::via_naming_service ()
{
try
{
@@ -174,8 +168,6 @@ Consumer_Handler::via_naming_service (void)
// the <_narrow> method.
this->server_ =
Notifier::_narrow (notifier_obj.in ());
-
-
}
catch (const CORBA::Exception& ex)
{
@@ -191,7 +183,6 @@ Consumer_Handler::via_naming_service (void)
int
Consumer_Handler::init (int argc, ACE_TCHAR **argv)
{
-
this->argc_ = argc;
this->argv_ = argv;
@@ -253,7 +244,6 @@ Consumer_Handler::init (int argc, ACE_TCHAR **argv)
}
else
{
-
if (this->ior_ == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"%s: no ior specified\n",
@@ -284,9 +274,8 @@ Consumer_Handler::init (int argc, ACE_TCHAR **argv)
}
int
-Consumer_Handler::run (void)
+Consumer_Handler::run ()
{
-
try
{
// Obtain and activate the RootPOA.
@@ -313,7 +302,6 @@ Consumer_Handler::run (void)
if (this->interactive_ == 0)
{
-
// Register with the server.
this->server_->register_callback (this->stock_name_.c_str (),
this->threshold_value_,
@@ -329,7 +317,6 @@ Consumer_Handler::run (void)
// Run the ORB.
this->orb_->run ();
-
}
catch (const CORBA::Exception& ex)
{
diff --git a/TAO/examples/Callback_Quoter/Consumer_Handler.h b/TAO/examples/Callback_Quoter/Consumer_Handler.h
index de5d729bc63..71d4b469979 100644
--- a/TAO/examples/Callback_Quoter/Consumer_Handler.h
+++ b/TAO/examples/Callback_Quoter/Consumer_Handler.h
@@ -1,5 +1,3 @@
-/* -*- C++ -*- */
-
//=============================================================================
/**
* @file Consumer_Handler.h
@@ -10,7 +8,6 @@
*/
//=============================================================================
-
#ifndef CONSUMER_HANDLER_H
#define CONSUMER_HANDLER_H
@@ -45,16 +42,16 @@ class Consumer_Handler
{
public:
/// Constructor.
- Consumer_Handler (void);
+ Consumer_Handler ();
/// Destructor.
- ~Consumer_Handler (void);
+ ~Consumer_Handler ();
/// Initialize the client communication with the server.
int init (int argc, ACE_TCHAR *argv[]);
/// Start the ORB object.
- int run (void);
+ int run ();
/// the name of the stock the consumer is interested in.
ACE_CString stock_name_;
@@ -66,7 +63,7 @@ public:
Notifier_var server_;
/// The consumer object.
- Consumer_i *consumer_servant_;
+ Consumer_i *consumer_servant_ {};
/// Pointer to the consumer object registered with the ORB.
Callback_Quoter::Consumer_var consumer_var_;
@@ -83,7 +80,6 @@ public:
int unregistered_;
private:
-
/// Our orb.
CORBA::ORB_var orb_;
@@ -92,11 +88,11 @@ private:
/// Parse the command line arguments. Returns 0 on success, -1 on
/// error.
- int parse_args (void);
+ int parse_args ();
- /// This method initialises the naming service and registers the
+ /// This method initializes the naming service and registers the
/// object with the POA.
- int via_naming_service (void);
+ int via_naming_service ();
/// # of arguments on the command line.
int argc_;
diff --git a/TAO/examples/Callback_Quoter/Consumer_Input_Handler.cpp b/TAO/examples/Callback_Quoter/Consumer_Input_Handler.cpp
index fb97e50820c..004dc0f4733 100644
--- a/TAO/examples/Callback_Quoter/Consumer_Input_Handler.cpp
+++ b/TAO/examples/Callback_Quoter/Consumer_Input_Handler.cpp
@@ -8,17 +8,15 @@
*/
//=============================================================================
-
#include "Consumer_Input_Handler.h"
#include "ace/Read_Buffer.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_NS_ctype.h"
Consumer_Input_Handler::Consumer_Input_Handler (Consumer_Handler *consumer_handler)
- {
- consumer_handler_ = consumer_handler;
-
- }
+{
+ consumer_handler_ = consumer_handler;
+}
int
Consumer_Input_Handler::handle_input (ACE_HANDLE)
@@ -28,10 +26,7 @@ Consumer_Input_Handler::handle_input (ACE_HANDLE)
// The string could read contains \n\0 hence using ACE_OS::read
// which returns the no of bytes read and hence i can manipulate
// and remove the devil from the picture i.e '\n' ! ;)
-
- ssize_t strlen = ACE_OS::read (ACE_STDIN,
- buf,
- sizeof buf);
+ ssize_t strlen = ACE_OS::read (ACE_STDIN, buf, sizeof buf);
if (buf[strlen -1] == '\n')
buf[strlen -1] = '\0';
@@ -56,20 +51,15 @@ Consumer_Input_Handler::handle_input (ACE_HANDLE)
return 0;
}
-
int
Consumer_Input_Handler::register_consumer ()
{
-
// Get the stockname the consumer is interested in.
static char stockname[BUFSIZ];
- ACE_DEBUG ((LM_DEBUG,
- "Stockname?"));
+ ACE_DEBUG ((LM_DEBUG, "Stockname?"));
- ssize_t strlen = ACE_OS::read (ACE_STDIN,
- stockname,
- sizeof stockname - 1);
+ ssize_t strlen = ACE_OS::read (ACE_STDIN, stockname, sizeof stockname - 1);
// Taking care of platforms where an carriage return is padded with newline.
if (stockname[strlen -2] == '\n' || stockname[strlen -2] == '\r')
@@ -78,7 +68,6 @@ Consumer_Input_Handler::register_consumer ()
if (stockname[strlen -1] == '\n' || stockname[strlen -1] == '\r')
stockname[strlen -1] = '\0';
-
this->consumer_handler_->stock_name_ = stockname;
// Get the threshold value.
@@ -99,7 +88,6 @@ Consumer_Input_Handler::register_consumer ()
try
{
-
// Register with the server.
this->consumer_handler_->server_->register_callback (this->consumer_handler_->stock_name_.c_str (),
this->consumer_handler_->threshold_value_,
@@ -110,9 +98,7 @@ Consumer_Input_Handler::register_consumer ()
consumer_handler_->unregistered_ = 0;
// @@ Up to this point..
-
- ACE_DEBUG ((LM_DEBUG,
- "registeration done!\n"));
+ ACE_DEBUG ((LM_DEBUG, "Registration done!\n"));
}
catch (const CORBA::Exception& ex)
{
@@ -124,14 +110,11 @@ Consumer_Input_Handler::register_consumer ()
return 0;
}
-
-
int
Consumer_Input_Handler::unregister_consumer ()
{
// Only if the consumer is registered can the
// unregistration take place.
-
if (consumer_handler_->registered_ == 1)
{
this->consumer_handler_->server_->unregister_callback (this->consumer_handler_->consumer_var_.in());
@@ -145,7 +128,6 @@ Consumer_Input_Handler::unregister_consumer ()
ACE_DEBUG ((LM_DEBUG,
" Invalid Operation: Consumer not Registered\n"));
-
return 0;
}
@@ -192,8 +174,3 @@ Consumer_Input_Handler::quit_consumer_process ()
return 0;
}
-
-Consumer_Input_Handler::~Consumer_Input_Handler (void)
-{
- // No-op
-}
diff --git a/TAO/examples/Callback_Quoter/Consumer_Input_Handler.h b/TAO/examples/Callback_Quoter/Consumer_Input_Handler.h
index 883673c2251..89f857d14c3 100644
--- a/TAO/examples/Callback_Quoter/Consumer_Input_Handler.h
+++ b/TAO/examples/Callback_Quoter/Consumer_Input_Handler.h
@@ -25,7 +25,6 @@
// Creating a class to handle input events.
// Since only inputs need to be handled, only the handle_input
// method is overlaoded.
-
class Consumer_Handler;
/**
@@ -39,49 +38,45 @@ class Consumer_Handler;
*/
class Consumer_Input_Handler : public ACE_Event_Handler
{
-
public:
/// Constructor.
Consumer_Input_Handler (Consumer_Handler *consumer_handler);
/// Handle the user input.
- int handle_input (ACE_HANDLE);
+ int handle_input (ACE_HANDLE) override;
/// Registration with the notifier.
- int register_consumer (void);
+ int register_consumer ();
/// Cancelling the registration with the notifier.
- int unregister_consumer (void);
+ int unregister_consumer ();
/// Ends the consumer process.
- int quit_consumer_process (void);
-
- enum
+ int quit_consumer_process ();
+
+ /// A set of values for the execution of the consumer.
+ ///
+ /// Used so that the process of registering, unregistering
+ /// and exiting neednt be dependent on 'r' 'u' and 'q'.
+ /// Also, #define clutters up the global namespace.
+enum
{
- // = TITLE
- // A set of values for the execution of the consumer.
- //
- // = DESCRIPTION
- // Used so that the process of registering, unregistering
- // and exiting neednt be dependent on 'r' 'u' and 'q'.
- // Also, #define clutters up the global namespace.
-
+ /// The character that the user must type to register the consumer with
+ /// the Notifier_server.
REGISTER = 'r',
- // The character that the user must type to register the consumer with
- // the Notifier_server.
+ /// The character that the user must type to unregister the consumer with
+ /// the Notifier_server.
UNREGISTER = 'u',
- // The character that the user must type to unregister the consumer with
- // the Notifier_server.
+ /// The character the user must type to quit the consumer client
+ /// application.
EXIT = 'q'
- // The character the user must type to quit the consumer client
- // application.
};
protected:
- /// the destructor.
- ~Consumer_Input_Handler (void);
+ /// Destructor.
+ ~Consumer_Input_Handler () = default;
private:
/// The Consumer_Handler object.
diff --git a/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.cpp b/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.cpp
index 9298cad5ce2..0d7f1084e24 100644
--- a/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.cpp
+++ b/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.cpp
@@ -10,7 +10,6 @@
*/
//=============================================================================
-
#include "Consumer_Signal_Handler.h"
Consumer_Signal_Handler::Consumer_Signal_Handler (Consumer_Handler *consumer_handler)
@@ -18,18 +17,13 @@ Consumer_Signal_Handler::Consumer_Signal_Handler (Consumer_Handler *consumer_han
{
}
-Consumer_Signal_Handler:: ~Consumer_Signal_Handler (void)
-{
-}
-
// Method to handle the ^C signal.
int
Consumer_Signal_Handler::handle_signal (int /* signum */,
siginfo_t*,
ucontext_t*)
{
- ACE_DEBUG ((LM_DEBUG,
- " Exiting on receiving ^C\n"));
+ ACE_DEBUG ((LM_DEBUG, " Exiting on receiving ^C\n"));
quit_on_signal ();
@@ -38,8 +32,7 @@ Consumer_Signal_Handler::handle_signal (int /* signum */,
// Method called before the Event_Handler dies.
int
-Consumer_Signal_Handler::handle_close (ACE_HANDLE,
- ACE_Reactor_Mask)
+Consumer_Signal_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
{
// End of the signal handler.
delete this;
@@ -48,12 +41,10 @@ Consumer_Signal_Handler::handle_close (ACE_HANDLE,
}
int
-Consumer_Signal_Handler::quit_on_signal (void)
+Consumer_Signal_Handler::quit_on_signal ()
{
// Only if the consumer is registered and wants to shut down, its
// necessary to unregister and then shutdown.
-
-
try
{
if (consumer_handler_->unregistered_ != 1
diff --git a/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.h b/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.h
index 9cd7463ae4e..6043fd02f4e 100644
--- a/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.h
+++ b/TAO/examples/Callback_Quoter/Consumer_Signal_Handler.h
@@ -31,32 +31,30 @@ class Consumer_Handler;
class Consumer_Signal_Handler : public ACE_Event_Handler
{
public:
-
- /// The consumer_handler refernce will be used to access the servant
+ /// The consumer_handler reference will be used to access the servant
/// methods.
Consumer_Signal_Handler (Consumer_Handler *consumer_handler);
/// This method takes action on an signal event.
int handle_signal (int signum,
siginfo_t*,
- ucontext_t*);
+ ucontext_t*) override;
/**
* For removal of the signal handler from the dispatch tables. When
* the handle_signal () returns < 0 this method will be executed
* automatically.
*/
- int handle_close (ACE_HANDLE handle,
- ACE_Reactor_Mask close_mask);
+ int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) override;
protected:
/// Protected destructor so that the signal handler is always created
/// dynamically and hence the heap doesnt get corrupted.
- ~Consumer_Signal_Handler (void);
+ ~Consumer_Signal_Handler () = default;
private:
/// Exit gracefully on a signal.
- int quit_on_signal (void);
+ int quit_on_signal ();
/// Reference to the Consumer_Handler which is used in accessing the
/// servant methods.
diff --git a/TAO/examples/Callback_Quoter/Consumer_i.cpp b/TAO/examples/Callback_Quoter/Consumer_i.cpp
index 35f47f2df2d..2e37f82b1c6 100644
--- a/TAO/examples/Callback_Quoter/Consumer_i.cpp
+++ b/TAO/examples/Callback_Quoter/Consumer_i.cpp
@@ -10,17 +10,8 @@
*/
//=============================================================================
-
#include "Consumer_i.h"
-Consumer_i::Consumer_i (void)
-{
-}
-
-Consumer_i::~Consumer_i (void)
-{
-}
-
void
Consumer_i::push (const Callback_Quoter::Info &data)
{
@@ -34,11 +25,9 @@ Consumer_i::push (const Callback_Quoter::Info &data)
}
void
-Consumer_i::shutdown (void)
+Consumer_i::shutdown ()
{
-
// Instruct the ORB to shutdown.
-
ACE_DEBUG ((LM_DEBUG,
" consumer shutting down \n"));
diff --git a/TAO/examples/Callback_Quoter/Consumer_i.h b/TAO/examples/Callback_Quoter/Consumer_i.h
index 23fa3e574e0..c9c85e1534d 100644
--- a/TAO/examples/Callback_Quoter/Consumer_i.h
+++ b/TAO/examples/Callback_Quoter/Consumer_i.h
@@ -29,16 +29,16 @@ class Consumer_i : public POA_Callback_Quoter::Consumer
{
public:
/// Constructor.
- Consumer_i (void);
+ Consumer_i () = default;
/// Destructor.
- ~Consumer_i (void);
+ ~Consumer_i () = default;
/// Gets the stock information from the Notifier.
- void push (const Callback_Quoter::Info & data);
+ void push (const Callback_Quoter::Info & data) override;
/// Used to get the consumer to shut down.
- virtual void shutdown (void);
+ void shutdown () override;
/// Set the ORB pointer.
void orb (CORBA::ORB_ptr o);
@@ -47,9 +47,6 @@ private:
/// ORB pointer.
CORBA::ORB_var orb_;
- /// If 1 denotes that the consumer is dead else alive.
- int quit_;
-
// @@ Please rename to Notifier.
/// Smart pointer to the Notifier object.
Notifier_var server_;
diff --git a/TAO/examples/Callback_Quoter/Notifier.idl b/TAO/examples/Callback_Quoter/Notifier.idl
index bfce4c6eb7c..cb46d0f0932 100644
--- a/TAO/examples/Callback_Quoter/Notifier.idl
+++ b/TAO/examples/Callback_Quoter/Notifier.idl
@@ -4,30 +4,28 @@
#include "Consumer.idl"
+/// The Notifier interface in the Callback_Quoter example which
+/// contains the methods by which the consumer can register,
+/// unregister from the Notifier.
interface Notifier
{
- // = TITLE
- // The Notifier interface in the Callback_Quoter example which
- // contains the methods by which the consumer can register,
- // unregister from the Notifier.
-
+ /// Register a distributed callback handler that is invoked when the
+ /// given stock reaches the desired threshold value.
void register_callback (in string stock_name,
in long threshold_value,
in Callback_Quoter::Consumer consumer_handler)
raises (Callback_Quoter::Invalid_Stock);
- // Register a distributed callback handler that is invoked when the
- // given stock reaches the desired threshold value.
+ /// Remove the handler.
void unregister_callback (in Callback_Quoter::Consumer consumer_handler)
raises (Callback_Quoter::Invalid_Handle);
- // Remove the handler.
+ /// Get market status.
void market_status (in string stock_name,
in long stock_value);
- // Get market status.
- void shutdown ();
- // Shuts the server down.
+ /// Shuts the server down.
+ void shutdown ();
};
#endif /* _NOTIFIER_IDL */
diff --git a/TAO/examples/Callback_Quoter/Notifier_Input_Handler.cpp b/TAO/examples/Callback_Quoter/Notifier_Input_Handler.cpp
index 112232beb13..d88b3ad1849 100644
--- a/TAO/examples/Callback_Quoter/Notifier_Input_Handler.cpp
+++ b/TAO/examples/Callback_Quoter/Notifier_Input_Handler.cpp
@@ -1,4 +1,3 @@
-
//=============================================================================
/**
* @file Notifier_Input_Handler.cpp
@@ -9,7 +8,6 @@
*/
//=============================================================================
-
#include "Notifier_Input_Handler.h"
#include "tao/debug.h"
#include "tao/ORB_Core.h"
@@ -18,8 +16,7 @@
#include "ace/OS_NS_ctype.h"
// Constructor.
-
-Notifier_Input_Handler::Notifier_Input_Handler (void)
+Notifier_Input_Handler::Notifier_Input_Handler ()
: ior_output_file_ (0),
argc_ (0),
argv_ (0),
@@ -28,27 +25,22 @@ Notifier_Input_Handler::Notifier_Input_Handler (void)
}
// Destructor.
-
-Notifier_Input_Handler::~Notifier_Input_Handler (void)
+Notifier_Input_Handler::~Notifier_Input_Handler ()
{
// Make sure to cleanup the STDIN handler.
-
if (ACE_Event_Handler::remove_stdin_handler
(this->notifier_i_.orb_->orb_core ()->reactor (),
this->notifier_i_.orb_->orb_core ()->thr_mgr ()) == -1)
ACE_ERROR ((LM_ERROR,
"%p\n",
"remove_stdin_handler"));
-
}
// The naming service is initialized and the naming context as well as
// the object name is bound to the naming server.
-
int
-Notifier_Input_Handler::init_naming_service (void)
+Notifier_Input_Handler::init_naming_service ()
{
-
CORBA::ORB_var orb = this->orb_manager_.orb ();
if (this->naming_server_.init (orb.in ()) == -1)
@@ -68,7 +60,6 @@ Notifier_Input_Handler::init_naming_service (void)
naming_server_->rebind (notifier_obj_name,
notifier_obj.in());
-
}
catch (const CosNaming::NamingContext::AlreadyBound&)
{
@@ -83,7 +74,7 @@ Notifier_Input_Handler::init_naming_service (void)
// Parse the command-line arguments and set options.
int
-Notifier_Input_Handler::parse_args (void)
+Notifier_Input_Handler::parse_args ()
{
ACE_Get_Opt get_opts (this->argc_, this->argv_, ACE_TEXT("df:s "));
int c;
@@ -125,15 +116,12 @@ Notifier_Input_Handler::parse_args (void)
}
// Initialize the server.
-
int
Notifier_Input_Handler::init (int argc,
ACE_TCHAR *argv[])
{
-
// Call the init of <TAO_ORB_Manager> to initialize the ORB and
// create the child poa under the root POA.
-
this->argc_ = argc;
this->argv_ = argv;
@@ -192,21 +180,16 @@ Notifier_Input_Handler::init (int argc,
}
int
-Notifier_Input_Handler::run (void)
+Notifier_Input_Handler::run ()
{
// Run the main event loop for the ORB.
+ ACE_DEBUG ((LM_DEBUG, " Type \"q\" to quit \n"));
-
- ACE_DEBUG ((LM_DEBUG,
- " Type \"q\" to quit \n"));
-
- int result = this->orb_manager_.run ();
+ int const result = this->orb_manager_.run ();
if (result == -1)
{
- ACE_ERROR_RETURN ((LM_ERROR,
- "Notifier_Input_Handler::run"),
- -1);
+ ACE_ERROR_RETURN ((LM_ERROR, "Notifier_Input_Handler::run"), -1);
}
return 0;
@@ -215,23 +198,19 @@ Notifier_Input_Handler::run (void)
int
Notifier_Input_Handler::handle_input (ACE_HANDLE)
{
- char buf[BUFSIZ];
-
-
try
{
+ char buf[BUFSIZ];
+
// The string could read contains \n\0 hence using ACE_OS::read
// which returns the no of bytes read and hence i can manipulate
// and remove the devil from the picture i.e '\n' ! ;)
-
- ssize_t strlen = ACE_OS::read (ACE_STDIN,
- buf,
- sizeof buf);
+ ssize_t const strlen = ACE_OS::read (ACE_STDIN, buf, sizeof buf);
if (buf[strlen -1] == '\n')
buf[strlen -1] = '\0';
ACE_DEBUG ((LM_DEBUG,
- "%s",
+ "%C",
buf));
if (ACE_OS::ace_tolower(buf[0]) == 'q')
diff --git a/TAO/examples/Callback_Quoter/Notifier_Input_Handler.h b/TAO/examples/Callback_Quoter/Notifier_Input_Handler.h
index a19bbeabf5e..e26fa584eba 100644
--- a/TAO/examples/Callback_Quoter/Notifier_Input_Handler.h
+++ b/TAO/examples/Callback_Quoter/Notifier_Input_Handler.h
@@ -34,32 +34,30 @@ class Notifier_Input_Handler : public ACE_Event_Handler
{
public:
/// Constructor.
- Notifier_Input_Handler (void);
+ Notifier_Input_Handler ();
/// Destructor.
- ~Notifier_Input_Handler (void);
+ ~Notifier_Input_Handler ();
/// Initialize the Notifier who plays the role of the server here.
- int init (int argc,
- ACE_TCHAR *argv[]);
+ int init (int argc, ACE_TCHAR *argv[]);
/// Run the ORB.
- int run (void);
+ int run ();
/// Handle the user input.
- virtual int handle_input (ACE_HANDLE);
+ int handle_input (ACE_HANDLE) override;
private:
-
- /// The tao orb manager object.
+ /// The TAO orb manager object.
TAO_ORB_Manager orb_manager_;
/// Parses the command line arguments.
- int parse_args (void);
+ int parse_args ();
/// Initialises the name server and registers the Notifier object
/// name with the name server.
- int init_naming_service (void);
+ int init_naming_service ();
/// File where the IOR of the Notifier object is stored.
FILE *ior_output_file_;
diff --git a/TAO/examples/Callback_Quoter/Notifier_i.cpp b/TAO/examples/Callback_Quoter/Notifier_i.cpp
index 64855f0766d..675bfedf1e1 100644
--- a/TAO/examples/Callback_Quoter/Notifier_i.cpp
+++ b/TAO/examples/Callback_Quoter/Notifier_i.cpp
@@ -10,24 +10,10 @@
*/
//=============================================================================
-
#include "Notifier_i.h"
-
-Notifier_i::Notifier_i (void)
- : notifier_exited_(0)
-{
- // No-op
-}
-
-Notifier_i::~Notifier_i (void)
-{
- // No-op
-}
-
// Register a distributed callback handler that is invoked when the
// given stock reaches the desired threshold value.
-
void
Notifier_i::register_callback (const char *stock_name,
CORBA::Long threshold_value,
@@ -88,7 +74,6 @@ Notifier_i::register_callback (const char *stock_name,
}
// Obtain a pointer to the orb.
-
void
Notifier_i::orb (CORBA::ORB_ptr orb)
{
@@ -96,7 +81,6 @@ Notifier_i::orb (CORBA::ORB_ptr orb)
}
// Remove the client handler.
-
void
Notifier_i::unregister_callback (Callback_Quoter::Consumer_ptr consumer)
{
@@ -140,13 +124,12 @@ Notifier_i::unregister_callback (Callback_Quoter::Consumer_ptr consumer)
// Gets the market status and sends the information to the consumer
// who is interested in it.
-
void
Notifier_i::market_status (const char *stock_name,
CORBA::Long stock_value)
{
ACE_DEBUG ((LM_DEBUG,
- "Notifier_i:: The stockname is %s with price %d\n",
+ "Notifier_i:: The stockname is %C with price %d\n",
stock_name,
stock_value));
@@ -186,11 +169,10 @@ Notifier_i::market_status (const char *stock_name,
" Stock Not Present!\n"));
// Raising an exception caused problems as they were caught by the Market daemon
// who exited prematurely.
-
}
void
-Notifier_i::shutdown (void)
+Notifier_i::shutdown ()
{
if ( this->consumer_map_.close () > 0)
ACE_ERROR ((LM_ERROR,
@@ -206,7 +188,6 @@ Notifier_i::shutdown (void)
// Instruct the ORB to shutdown.
this->orb_->shutdown ();
-
}
bool
@@ -219,4 +200,3 @@ Notifier_i::Consumer_Data::operator== (const Consumer_Data &rhs) const
return this->consumer_->_is_equivalent (rhs.consumer_.in ());
}
-
diff --git a/TAO/examples/Callback_Quoter/Notifier_i.h b/TAO/examples/Callback_Quoter/Notifier_i.h
index 23a283c28c7..283c6611f9a 100644
--- a/TAO/examples/Callback_Quoter/Notifier_i.h
+++ b/TAO/examples/Callback_Quoter/Notifier_i.h
@@ -38,34 +38,30 @@ class Notifier_i : public POA_Notifier
{
public:
/// Constructor.
- Notifier_i (void);
+ Notifier_i () = default;
/// Destructor.
- ~Notifier_i (void);
+ ~Notifier_i () = default;
/// Register a distributed callback handler that is invoked when the
/// given stock reaches the desired threshold value.
- virtual void register_callback (const char *stock_name,
- CORBA::Long threshold_value,
- Callback_Quoter::Consumer_ptr consumer_handler);
+ void register_callback (const char *stock_name,
+ CORBA::Long threshold_value,
+ Callback_Quoter::Consumer_ptr consumer_handler) override;
/// Remove the consumer object.
- virtual void unregister_callback (Callback_Quoter::Consumer_ptr consumer_handler);
+ void unregister_callback (Callback_Quoter::Consumer_ptr consumer_handler) override;
+
/// Get the market status.
- virtual void market_status (const char *stock_name,
- CORBA::Long stock_value);
+ void market_status (const char *stock_name, CORBA::Long stock_value) override;
/// Get the orb pointer.
void orb (CORBA::ORB_ptr orb);
/// Shutdown the Notifier.
- virtual void shutdown (void);
-
- // CONSUMER_MAP* get_consumer_map_ptr ();
- // Returns the consumer map ptr.
+ void shutdown () override;
- //private:
public:
/// The ORB manager.
CORBA::ORB_var orb_;
@@ -88,11 +84,9 @@ public:
CORBA::Long desired_value_;
};
- typedef ACE_Unbounded_Set<Consumer_Data>
- CONSUMERS;
+ typedef ACE_Unbounded_Set<Consumer_Data> CONSUMERS;
- typedef ACE_Hash_Map_Manager<ACE_CString, CONSUMERS *, ACE_Null_Mutex>
- CONSUMER_MAP;
+ typedef ACE_Hash_Map_Manager<ACE_CString, CONSUMERS *, ACE_Null_Mutex> CONSUMER_MAP;
/// This is the hash map with each hash_entry consisting of the stockname
/// and an unbounded set of consumer object pointer and the desired stockvalue.
@@ -100,9 +94,7 @@ public:
///This marks the exit of the notifier. This should be taken care of
/// before the consumer tries to unregister after the notifier quits.
- int notifier_exited_;
-
-
+ int notifier_exited_ {0};
};
#endif /* NOTIFIER_I_H */
diff --git a/TAO/examples/Callback_Quoter/README b/TAO/examples/Callback_Quoter/README
index 71c1aee8d2c..efda13a1935 100644
--- a/TAO/examples/Callback_Quoter/README
+++ b/TAO/examples/Callback_Quoter/README
@@ -1,5 +1,3 @@
-
-
******************************************************************************
CALLBACK QUOTER TEST EXAMPLE -- Kirthika Parameswaran
<kirthika@cs.wustl.edu>
@@ -15,7 +13,6 @@ There are three parts to the Callback Quoter Example.
2) Notifier
3) Consumer
-
In detail:
_________
@@ -59,8 +56,6 @@ There are 3 parts to it:
./notifier
-
-
2) shell 2: type at the command prompt:
./consumer
@@ -71,8 +66,6 @@ Now wait for information to arrive.
You can unregister by typing 'u' and quit by typing 'q'.
-
-
3) shell 3: type at the command prompt:
./supplier -ifilename
@@ -94,8 +87,6 @@ There are 3 parts to it:
./notifier -fior_file -s
-
-
2) shell 2: type at the command prompt:
./consumer -fior_file -s
@@ -106,8 +97,6 @@ Now wait for information to arrive.
You can unregister by typing 'u' and quit by typing 'q'.
-
-
3) shell 3: type at the command prompt:
./supplier -ifilename -fior_file -s
diff --git a/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.cpp b/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.cpp
index 23ec944277b..b984aa94fc7 100644
--- a/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.cpp
+++ b/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.cpp
@@ -6,14 +6,11 @@
*/
//=============================================================================
-
#include "ace/ACE.h"
-
#include "Supplier_Timer_Handler.h"
// The supplier refernce is got so that the mathods in the supplier
// can be accessed.
-
Supplier_Timer_Handler:: Supplier_Timer_Handler (Supplier *supplier,
ACE_Reactor *reactor,
FILE *file_ptr)
@@ -21,23 +18,13 @@ Supplier_Timer_Handler:: Supplier_Timer_Handler (Supplier *supplier,
reactor_ (reactor),
file_ptr_ (file_ptr)
{
- // No-op.
-}
-
-// Destructor.
-
- Supplier_Timer_Handler::~Supplier_Timer_Handler (void)
-{
- // No-op.
}
// Method which will be called by the reactor on timeout.
-
int
Supplier_Timer_Handler:: handle_timeout (const ACE_Time_Value & /* tv */,
const void * /* arg */)
{
-
ACE_DEBUG ((LM_DEBUG,
"Sending Stock Market Information to Notifier...\n"));
@@ -62,9 +49,8 @@ Supplier_Timer_Handler:: handle_timeout (const ACE_Time_Value & /* tv */,
}
// Get the stock information from a file.
-
int
-Supplier_Timer_Handler::get_stock_information (void)
+Supplier_Timer_Handler::get_stock_information ()
{
// Scan the file and obtain the stock information.
if (fscanf (file_ptr_,
@@ -85,4 +71,3 @@ Supplier_Timer_Handler::get_stock_information (void)
return -1;
}
}
-
diff --git a/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.h b/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.h
index 8d20adf09fa..913815fb0c1 100644
--- a/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.h
+++ b/TAO/examples/Callback_Quoter/Supplier_Timer_Handler.h
@@ -10,7 +10,6 @@
*/
//=============================================================================
-
#ifndef SUPPLIER_TIMER_HANDLER_H
#define SUPPLIER_TIMER_HANDLER_H
#include "ace/Reactor.h"
@@ -36,22 +35,20 @@ class Supplier;
class Supplier_Timer_Handler : public ACE_Event_Handler
{
public:
- /// Initilization.
+ /// Initialization.
Supplier_Timer_Handler (Supplier *supplier,
ACE_Reactor *reactor,
FILE *file_ptr);
/// Destructor.
- ~Supplier_Timer_Handler (void);
+ ~Supplier_Timer_Handler () = default;
/// Method which will be called by the Reactor when timeout occurs.
- virtual int handle_timeout (const ACE_Time_Value &tv,
- const void *arg = 0);
+ int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0) override;
private:
-
/// The values of the stock and its rate are got from the file.
- int get_stock_information (void);
+ int get_stock_information ();
/// The supplier instance.
Supplier *supplier_obj_;
diff --git a/TAO/examples/Callback_Quoter/Supplier_i.cpp b/TAO/examples/Callback_Quoter/Supplier_i.cpp
index 7e48e7d3af4..97b4b7ae79f 100644
--- a/TAO/examples/Callback_Quoter/Supplier_i.cpp
+++ b/TAO/examples/Callback_Quoter/Supplier_i.cpp
@@ -8,7 +8,6 @@
*/
//=============================================================================
-
#include "Supplier_i.h"
#include "tao/debug.h"
#include "ace/Get_Opt.h"
@@ -20,8 +19,7 @@
#include "ace/OS_NS_fcntl.h"
// Constructor.
-
-Supplier::Supplier (void)
+Supplier::Supplier ()
: ior_ (0),
use_naming_service_ (1),
notifier_ (),
@@ -29,10 +27,9 @@ Supplier::Supplier (void)
loop_count_ (10),
period_value_ (1)
{
- // No-op.
}
-Supplier::~Supplier (void)
+Supplier::~Supplier ()
{
// Release the memory allocated for ior_.
ACE_OS::free (this->ior_);
@@ -45,7 +42,6 @@ Supplier::~Supplier (void)
}
// Reads the Server factory IOR from a file.
-
int
Supplier::read_ior (ACE_TCHAR *filename)
{
@@ -75,9 +71,8 @@ Supplier::read_ior (ACE_TCHAR *filename)
}
// Parses the command line arguments and returns an error status.
-
int
-Supplier::parse_args (void)
+Supplier::parse_args ()
{
ACE_Get_Opt get_opts (argc_, argv_, ACE_TEXT("dn:f:i:xk:xs"));
@@ -142,15 +137,11 @@ Supplier::parse_args (void)
}
// Give the stock status information to the Notifier.
-
int
-Supplier::send_market_status (const char *stock_name,
- long value)
+Supplier::send_market_status (const char *stock_name, long value)
{
-
try
{
-
// Make the RMI.
this->notifier_->market_status (stock_name,
value);
@@ -171,11 +162,9 @@ Supplier::send_market_status (const char *stock_name,
}
// Execute client example code.
-
int
-Supplier::run (void)
+Supplier::run ()
{
-
long timer_id = 0;
ACE_DEBUG ((LM_DEBUG,
@@ -199,11 +188,9 @@ Supplier::run (void)
return this->reactor_used ()->run_reactor_event_loop ();
}
-
int
-Supplier::via_naming_service (void)
+Supplier::via_naming_service ()
{
-
try
{
// Initialization of the naming service.
@@ -241,7 +228,6 @@ Supplier::via_naming_service (void)
}
// Init function.
-
int
Supplier::init (int argc, ACE_TCHAR **argv)
{
@@ -305,7 +291,6 @@ Supplier::reactor_used () const
}
// The stock market information is read from a file.
-
int
Supplier::read_file (ACE_TCHAR *filename)
{
diff --git a/TAO/examples/Callback_Quoter/Supplier_i.h b/TAO/examples/Callback_Quoter/Supplier_i.h
index 3af4b7fefe1..69a37aed83a 100644
--- a/TAO/examples/Callback_Quoter/Supplier_i.h
+++ b/TAO/examples/Callback_Quoter/Supplier_i.h
@@ -37,13 +37,13 @@ class Supplier
{
public:
/// Constructor.
- Supplier (void);
+ Supplier ();
/// Destructor.
- ~Supplier (void);
+ ~Supplier ();
/// Execute the daemon.
- int run (void);
+ int run ();
/// Initialize the client communication endpoint with Notifier.
int init (int argc, ACE_TCHAR *argv[]);
@@ -52,11 +52,11 @@ public:
int send_market_status (const char *stock_name,
long value);
+private:
/// The timer handler used to send the market status to the notifier
/// periodically.
- Supplier_Timer_Handler *supplier_timer_handler_;
+ Supplier_Timer_Handler *supplier_timer_handler_ {};
-private:
/// Remember our orb.
CORBA::ORB_var orb_;
@@ -64,11 +64,11 @@ private:
int read_ior (ACE_TCHAR *filename);
/// Parses the arguments passed on the command line.
- int parse_args (void);
+ int parse_args ();
/// This method initialises the naming service and registers the
/// object with the POA.
- int via_naming_service(void);
+ int via_naming_service();
/// returns the TAO instance of the singleton Reactor.
ACE_Reactor *reactor_used () const;
diff --git a/TAO/examples/Callback_Quoter/consumer.cpp b/TAO/examples/Callback_Quoter/consumer.cpp
index d270936307c..b286500b79f 100644
--- a/TAO/examples/Callback_Quoter/consumer.cpp
+++ b/TAO/examples/Callback_Quoter/consumer.cpp
@@ -1,7 +1,6 @@
#include "Consumer_Handler.h"
// This function runs the Callback Quoter Consumer application.
-
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
diff --git a/TAO/examples/Callback_Quoter/notifier.cpp b/TAO/examples/Callback_Quoter/notifier.cpp
index dde220c305c..27f9be21919 100644
--- a/TAO/examples/Callback_Quoter/notifier.cpp
+++ b/TAO/examples/Callback_Quoter/notifier.cpp
@@ -1,14 +1,12 @@
#include "Notifier_Input_Handler.h"
// This is the main driver program for the Callback Quoter Notifier.
-
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
Notifier_Input_Handler notifier;
- ACE_DEBUG ((LM_DEBUG,
- "\n\tNotifier\n\n"));
+ ACE_DEBUG ((LM_DEBUG, "\n\tNotifier\n\n"));
try
{
diff --git a/TAO/examples/Callback_Quoter/supplier.cpp b/TAO/examples/Callback_Quoter/supplier.cpp
index e4149bc9027..38391f529dd 100644
--- a/TAO/examples/Callback_Quoter/supplier.cpp
+++ b/TAO/examples/Callback_Quoter/supplier.cpp
@@ -1,7 +1,6 @@
#include "Supplier_i.h"
// This function runs the Callback Quoter Supplier daemon.
-
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{