summaryrefslogtreecommitdiff
path: root/apps/Gateway/Peer/Event.h
blob: 24881c3e85bb3732b6f2e7580941d66a368f7685 (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
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    apps
// 
// = FILENAME
//    Event.h
//
// = AUTHOR
//    Doug Schmidt 
// 
// ============================================================================

#if !defined (EVENT)
#define EVENT

#include "ace/OS.h"

// This is the unique connection identifier that denotes a particular
// Proxy_Handler in the Gateway.
typedef ACE_INT32 ACE_INT32;

class Event_Addr
  // = TITLE
  //     Address used to identify the source/destination of an event.
  //
  // = DESCRIPTION
  //     This is really a "virtual forwarding address" thatis used to
  //     decouple the filtering and forwarding logic of the Event
  //     Channel from the format of the data.
{
public:
  Event_Addr (ACE_INT32 cid = -1, 
	      u_char sid = 0, 
	      u_char type = 0)
    : conn_id_ (cid), 
      supplier_id_ (sid), 
      type_ (type) {}

  int operator== (const Event_Addr &event_addr) const
  {
    return this->conn_id_ == event_addr.conn_id_ 
      && this->supplier_id_ == event_addr.supplier_id_
      && this->type_ == event_addr.type_;
  }

  ACE_INT32 conn_id_;
  // Unique connection identifier that denotes a particular
  // Proxy_Handler.

  ACE_INT32 supplier_id_;
  // Logical ID.

  ACE_INT32 type_;
  // Event type.
};


class Event_Header
  // = TITLE
  //    Fixed sized header.
{
public:
  typedef ACE_INT32 SUPPLIER_ID;
  // Type used to forward events from gatewayd.

  enum
  {
    INVALID_ID = -1 // No peer can validly use this number.
  };

  SUPPLIER_ID supplier_id_;
  // Source ID.

  ACE_INT32 type_;
  // Event type.

  size_t len_;
  // Length of the entire event (including data payload) in bytes.
};

class Event
  // = TITLE
  //    Variable-sized event (data_ may be variable-sized between
  //    0 and MAX_PAYLOAD_SIZE).
{
public:
  enum { MAX_PAYLOAD_SIZE = 1024 };
  // The maximum size of an Event.

  Event_Header header_;
  // Event header.

  char data_[MAX_PAYLOAD_SIZE];
  // Event data.
};

#endif /* EVENT */