3 //=============================================================================
5 * @file BPR_Drivers_T.h
7 * This code factors out common class templates for use in
8 * the different possible implementations of the Timer_Queue
9 * based bounded packet relay example.
11 * @author Chris Gill <cdgill@cs.wustl.edu> and Douglas C. Schmidt <d.schmidt@vanderbilt.edu> Based on the Timer Queue Test example written by Carlos O'Ryan <coryan@cs.wustl.edu> and Douglas C. Schmidt <d.schmidt@vanderbilt.edu> and Sergio Flores-Gaitan <sergio@cs.wustl.edu>
13 //=============================================================================
16 #ifndef _BPR_DRIVERS_T_H_
17 #define _BPR_DRIVERS_T_H_
19 #include "ace/Functor.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 // Forward declarations.
26 class Input_Device_Wrapper_Base
;
27 class Output_Device_Wrapper_Base
;
30 * @class Bounded_Packet_Relay_Driver
32 * @brief This abstract base class provides a simple abstraction for a
33 * test driver for the bounded packet relay example.
35 * This is the place where the common code to test the different
36 * implementations of the timer queue resides. This class has
37 * the logic for the parse_commands () method, the run (),
38 * read_input () and get_next_request () methods. Subclasses can
39 * override these methods if there is some logic that is specific
40 * to that implementation.
43 class Bounded_Packet_Relay_Driver
47 Bounded_Packet_Relay_Driver ();
50 virtual ~Bounded_Packet_Relay_Driver ();
52 /// Breaks up the input string buffer into pieces and executes the
53 /// appropriate method to handle that operation.
54 virtual int parse_commands (const char *buf
);
57 * This is the main entry point for the driver. The user of the
58 * class should normally invoke this method. Returns 0 when
59 * successful, or 0 otherwise.
63 /// This internal method gets the next request from the user.
64 /// Returns -1 when user wants to exit. Returns 0 otherwise.
65 virtual int get_next_request ();
68 * Reads input from the user into the buffer <buf> with a maximum of
69 * <bufsiz> bytes. Returns the amount of bytes actually read
70 * Otherwise, a -1 is returned and errno is set to indicate the
73 virtual ssize_t
read_input (char *buf
, size_t bufsiz
);
75 /// Prints the user interface for the driver to STDERR.
76 virtual int display_menu () = 0;
78 /// Initializes values and operations for the driver.
79 virtual int init () = 0;
81 /// Get count of packets to send in a transmission.
82 u_long
packet_count ();
84 /// Set count of packets to send in a transmission.
85 void packet_count (u_long pc
);
87 /// Get rate at which input packets are to arrive.
88 u_long
arrival_period ();
90 /// Set rate at which input packets are to arrive.
91 void arrival_period (u_long ap
);
93 /// Get rate at which packets are to be relayed (usec).
94 u_long
send_period ();
96 /// Set rate at which packets are to be relayed (usec).
97 void send_period (u_long sp
);
99 /// Get limit on the duration of the transmission (usec).
100 u_long
duration_limit ();
102 /// Set limit on the duration of the transmission (usec).
103 void duration_limit (u_long dl
);
105 /// Get logging level.
106 int logging_level ();
108 /// Set logging level.
109 void logging_level (int ll
);
112 // = Major Driver Mechanisms
114 /// Timer queue for transmission timeouts.
117 // = Set of commands to be executed.
119 /// Set packet count command.
120 ACE_Command_Base
*packet_count_cmd_
;
122 /// Set arrival period command.
123 ACE_Command_Base
*arrival_period_cmd_
;
125 /// Set transmit period command.
126 ACE_Command_Base
*transmit_period_cmd_
;
128 /// Set duration limit command.
129 ACE_Command_Base
*duration_limit_cmd_
;
131 /// Set logging level command.
132 ACE_Command_Base
*logging_level_cmd_
;
134 /// Run transmission command.
135 ACE_Command_Base
*run_transmission_cmd_
;
137 /// Cancel transmission command.
138 ACE_Command_Base
*cancel_transmission_cmd_
;
140 /// Report statistics command.
141 ACE_Command_Base
*report_stats_cmd_
;
143 /// Shut down the driver.
144 ACE_Command_Base
*shutdown_cmd_
;
147 /// Count of packets to send in a transmission.
148 u_long packet_count_
;
150 /// Rate at which input packets are to arrive.
151 u_long arrival_period_
;
153 /// Rate at which packets are to be relayed (usec).
156 /// Limit on the duration of the transmission (usec).
157 u_long duration_limit_
;
163 #include "BPR_Drivers_T.cpp"
165 #endif /* _BPR_DRIVERS_T_H_ */