summaryrefslogtreecommitdiff
path: root/ace/CLASSIX/CLASSIX_Port.h
blob: 28d44a24ce5554e0f70f9840909d090f096a18a7 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    ace
// 
// = FILENAME
//    CLASSIX_Port.h
//
// = AUTHOR
//    Nokia Telecommunications
//
// ============================================================================

#if !defined (ACE_CLASSIX_PORT_H)
#define ACE_CLASSIX_PORT_H

#include "ace/Singleton.h"
#include "ace/CLASSIX/CLASSIX_OS.h"
#include "ace/CLASSIX/CLASSIX_Addr.h"


class ACE_Export ACE_CLASSIX_Port : public ACE_CLASSIX_Addr
{
    // = TITLE
    //    Defines the ClassiX IPC Port address format for "ACE Socket" like
    //    interfaces
    //    
    // = DESCRIPTION
    //   The port address contains two fields:
    //   a global unique identifier  and a local identifier.
    //   The global unique identifier is also referred to as the port address
    //   and the local identifier as the port no.
    //   
    // = NOTE
    //   In Chorus, one can always convert from a port unique identifier to
    //   a port no and vice versa.  This class is implemented based on this
    //   premise.
    //
    // = SEE ALSO
    //   <ACE_CLASSIX_PORT_Default>, <ACE_CLASSIX_Port_Core>
    //   
public:
    /* -----------------------------------------------------*/
    // = Initialization methods.
    ACE_CLASSIX_Port ();
    // Default constructor.
    // The address corresponds to the default port of the actor.
 
    ACE_CLASSIX_Port (const ACE_CLASSIX_Port &);
    // Copy constructor.
    ACE_CLASSIX_Port (const ACE_Addr &);
    // Copy constructor.

    ACE_CLASSIX_Port (const ACE_CLASSIX_Port_Core&);
    // Creates an <ACE_CLASSIX_Port> from <ACE_CLASSIX_Port_Core>

    ACE_CLASSIX_Port (const KnUniqueId& /* port_id */);  
    // Creates an <ACE_CLASSIX_Port> from the given <port_id>

    ACE_CLASSIX_Port (ACE_HANDLE /* port_no */);  
    // Creates an <ACE_CLASSIX_Port> from the given <port_no>

    ACE_CLASSIX_Port (void* /* location */, int /* length */);
    // Create an <ACE_CLASSIX_Port> from the address in raw format.

    ACE_CLASSIX_Port const&  operator =(ACE_Addr const&);


    /* -----------------------------------------------------*/
    // = ACCESS

    virtual int addr_to_string (ASYS_TCHAR addr[], size_t) const;
    // Transform the current <ACE_CLASSIX_Port> address into string format,
    // which is in the form "actor-id:port-number"

    int set (const KnUniqueId& /* port_id */);
    // Sets the <ACE_CLASSIX_Port_Basic> from a <port_id>

    virtual void set_addr (void * /* addr location */,
			   int /* len */);
    // Set the address as the one pointed to by the location pointer.
    // The address contains <len> bytes.
    // Would prefer to return the status, but the base class uses void.
    int set_handle (ACE_HANDLE /* port_no */);
    // Sets the <addr_> field from a <port_no>

    virtual void *get_addr (void) const;
    // Returns a pointer to the address:,
    // <ACE_CLASSIX_Port_Core::ipp_port_addr>
    virtual const KnUniqueId& get_id (void) const;
    // Returns a reference to the port id.
    virtual ACE_HANDLE get_handle (void) const;
    // Returns the port no.
    int is_configured(void) const;
    // Returns 1, if address information is proper; Returns 0 otherwise
    virtual ACE_CLASSIX_Addr::Addr_Type is_type(void) const;
    // returns PORT type

    /* -----------------------------------------------------*/
    // = Control
    // 
    virtual int enable(int   /* receive priority */) const;
    // Puts the port into the set of monitored ports.
    virtual int disable(void) const;
    // Removes the port from the set of monitored ports.
    virtual void clear(void);
    // Remove port information

    /* -----------------------------------------------------*/
    // = Comparison
    // 
    int operator == (const ACE_CLASSIX_Port &) const;
    // Compare two addresses for equality.  The addresses are considered
    // equal if they have the same content in the KnUniqueId address structure.

    int operator != (const ACE_CLASSIX_Port &) const;
    // Compare two addresses for inequality.

    /* -----------------------------------------------------*/
    // = Helper
    // 
    void dump (void) const;
    // Dump the state of an object.
    

    ACE_ALLOC_HOOK_DECLARE;
    // Declare the dynamic allocation hooks.

private:
    /* -----------------------------------------------------*/
    // = Direct initialization methods (useful after the object has been
    // constructed).
    // Will create/reset the port only if the port no was <ACE_CLASSIX_ANY>
    // Returns 0 on success, -1 otherwise.
    // 

    int set_ (const ACE_Addr &);
    // Sets the <ACE_CLASSIX_Port_Basic> from another <ACE_CLASSIX_Port_Basic>.


 
private:
    ACE_CLASSIX_Port_Core::Addr           addr_;
};

/* ------------------------------------------------------------------------- */
#if defined (__ACE_INLINE__)
#include "ace/CLASSIX/CLASSIX_Port.i"
#endif /* __ACE_INLINE__ */


#endif /* ACE_CLASSIX_PORT_H */