summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/EC_Config/ECConfig.h
blob: e0b3b1c2384d7b927c5d9cc396d63e79d1602fe9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = FILENAME
//   ECConfig
//
// = AUTHOR
//   Bryan Thrall (thrall@cse.wustl.edu)
//
// ============================================================================

#ifndef ECCONFIG_H
#define ECCONFIG_H

#include "ace/Array.h"
//#include "ace/Synch.h"
#include "ace/RW_Mutex.h"
#include "orbsvcs/RtecSchedulerS.h" //for POA_RtecScheduler
#include "orbsvcs/RtecSchedulerC.h"
#include "orbsvcs/RtecEventChannelAdminC.h"
#include "orbsvcs/Event/EC_Event_Channel.h"

#include "TestConfig.h"
#include "Consumer.h"
#include "TimeoutConsumer.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

namespace TestConfig {

typedef ACE_Array<RtecEventChannelAdmin::ProxyPushConsumer_var> ProxyList;
typedef ACE_Array<RtecScheduler::handle_t> ConfigList;
typedef ACE_Array<RtecEventComm::EventSourceID> SupplierIDList;
typedef ACE_Array<TimeBase::TimeT> PeriodList;
typedef ACE_Array<RtecScheduler::Importance_t> ImportanceList;
typedef ACE_Array<RtecScheduler::Criticality_t> CritList;

typedef ACE_Array<Consumer*> ConsumerList;
typedef ACE_Array<TimeoutConsumer*> SupplierList;

template <class SCHED_STRAT>
class ECConfig : public Test_Config {
public:
  ECConfig (void);

  virtual ~ECConfig (void);

  virtual int configure (TCFG_SET_WPTR configs);
  //does not take ownership of the Test_Config_Set but
  //needs to use the test_config_t in that set until
  //the ECConfig goes out of scope

  virtual int run (void);
  //If we try to distinguish between final-push and final-receipt,
  //that might be tracked in the Consumer (which would be easy as long
  //as filtering and correlation isn't used -- in that case, there
  //might be more than one receiver of an event, so you might get
  //multiple receipt-notices). There could also be a race-condition
  //problem between the various threads when reporting the receipt of
  //events.

protected:
  // TODO USE DEFAULTS FOR ANY OF THESE?

  virtual void initEC (ACE_ENV_SINGLE_ARG_DECL);

  void connect_suppliers (ACE_ENV_SINGLE_ARG_DECL);

  void disconnect_suppliers (ACE_ENV_SINGLE_ARG_DECL);

  void connect_consumers (ACE_ENV_SINGLE_ARG_DECL);

  void disconnect_consumers (ACE_ENV_SINGLE_ARG_DECL);

  virtual void reset (ACE_ENV_SINGLE_ARG_DECL);

private:

  void print_RT_Infos (ACE_Array<RtecScheduler::handle_t> cfg_set);

  static ACE_THR_FUNC_RETURN run_orb(void *data); //thread fcn for running ORB

  Test_Config_Set testcfgs;
  //copy of the currently configured Test_Config_Set
  //using the same test_config_t objects

  CORBA::ORB_var orb;

  PortableServer::POA_var poa;

  PortableServer::POAManager_var poa_manager;

  RtecEventChannelAdmin::EventChannel_var event_channel;

  RtecScheduler::Scheduler_var scheduler;

  TAO_EC_Event_Channel *ec_impl;

  SCHED_STRAT *sched_impl;

  ConsumerList consumers;

  SupplierList suppliers;

  PeriodList periods;

  ImportanceList importances;

  CritList crits;

  ACE_RW_Mutex* test_done;
  //TimeoutConsumers acquire read locks; when the ECConfig can acquire
  //a write lock, all TimeoutConsumers must've finished, so the test
  //is finished.

  int configured; //boolean
};

} /* namespace TestConfig */

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ECConfig.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("ECConfig.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#endif /* ECCONFIG_H */