summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/lib/Event_Utilities.cpp
blob: 75394f34e2bcb5901bc3836310db41a42ab29fea (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
//
// $Id$
//
#include "Event_Utilities.h"

#if !defined (__ACE_INLINE__)
#include "Event_Utilities.i"
#endif /* __ACE_INLINE__ */

ACE_ConsumerQOS_Factory::ACE_ConsumerQOS_Factory (void) :
  qos_ (),
  designator_set_ (0)
{
}

ACE_ConsumerQOS_Factory::~ACE_ConsumerQOS_Factory (void)
{
}

int
ACE_ConsumerQOS_Factory::start_conjunction_group (void)
{
  int l = qos_.dependencies.length ();
  qos_.dependencies.length (l + 1);
  qos_.dependencies[l].event_.type_ = ACE_ES_CONJUNCTION_DESIGNATOR;
  // TODO: qos_.dependencies[l].event_.data_.lval (0);
  designator_set_ = 1;
  return 0;
}

int
ACE_ConsumerQOS_Factory::start_disjunction_group (void)
{
  int l = qos_.dependencies.length ();
  qos_.dependencies.length (l + 1);
  qos_.dependencies[l].event_.type_ = ACE_ES_DISJUNCTION_DESIGNATOR;
  // TODO: qos_.dependencies[l].event_.data_.lval (0);
  designator_set_ = 1;
  return 0;
}

int
ACE_ConsumerQOS_Factory::insert (const RtecEventChannelAdmin::Dependency &subscribe)
{
  RtecScheduler::RT_Info dummy;
  // Make sure that a designator is first.
  if (designator_set_ == 0)
    {
      int l = qos_.dependencies.length ();
      qos_.dependencies.length (l + 1);
      qos_.dependencies[l].event_.type_ = ACE_ES_GLOBAL_DESIGNATOR;
      // TODO: IDL union qos_.dependencies[l].event_.data_.lval (0);
      designator_set_ = 1;
    }

  int l = qos_.dependencies.length ();
  qos_.dependencies.length (l + 1);
  qos_.dependencies[l] = subscribe;
  // TODO: IDL union qos_.dependencies[l].event_.data_.lval (0);
  return 0;
}

void event_debug (const char* p,
		  const RtecEventComm::Event& event)
{
  int l = ACE_OS::strlen (p);
  ACE_DEBUG ((LM_DEBUG,
	      "%*.*s - event.source: %d\n"
	      "%*.*s   event.type: %d\n"
	      "%*.*s   event.time: %f\n",
	      l, l, p, event.source_,
	      l, l, p, event.type_,
	      l, l, p, event.time_));
}

void
ACE_ConsumerQOS_Factory::debug (const RtecEventChannelAdmin::ConsumerQOS& qos)
{
  ACE_DEBUG ((LM_DEBUG, "ConsumerQOS { \n"));

  for (u_int i = 0; i < qos.dependencies.length (); ++i)
    {
      char buf[128];
      ACE_OS::sprintf (buf, " dep[%d]", i);
      event_debug (buf, qos.dependencies[i].event_);
      ACE_DEBUG ((LM_DEBUG, "%s  rt_info: %d\n",
		  buf, qos.dependencies[i].rt_info));
    }
  ACE_DEBUG ((LM_DEBUG, "}\n"));
}

// ************************************************************

ACE_SupplierQOS_Factory::ACE_SupplierQOS_Factory (void) :
  qos_ ()
{
}

int
ACE_SupplierQOS_Factory::insert (RtecEventComm::EventSourceID sid,
				 RtecEventComm::EventType type,
				 RtecScheduler::handle_t rt_info,
				 u_int ncalls)
{
  int l = qos_.publications_.length ();
  qos_.publications_.length (l + 1);
  qos_.publications_[l].event_.source_ = sid;
  qos_.publications_[l].event_.type_ = type;
  // TODO: IDL union qos_.publications_[l].event_.data_.lval (0);
  qos_.publications_[l].dependency_info_.rt_info = rt_info;
  qos_.publications_[l].dependency_info_.number_of_calls = ncalls;
  return 0;
}

void ACE_SupplierQOS_Factory::debug (const RtecEventChannelAdmin::SupplierQOS& qos)
{
  ACE_DEBUG ((LM_DEBUG, "ConsumerQOS { \n"));
  for (u_int i = 0; i < qos.publications_.length (); ++i)
    {
      char buf[128];
      ACE_OS::sprintf (buf, " publications[%d]", i);
      event_debug (buf, qos.publications_[i].event_);
      ACE_DEBUG ((LM_DEBUG,
		  "%s   dependency_info.rt_info: %d\n"
		  "%s   dependency_info.number_of_calls: %d\n",
		  buf, qos.publications_[i].dependency_info_.rt_info,
		  buf, qos.publications_[i].dependency_info_.number_of_calls));
	}
  ACE_DEBUG ((LM_DEBUG, "}\n"));

}