summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Trader/Link.h
blob: b1d774b51cf4082219cd7ec31f8516ddcefb8e37 (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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/* -*- C++ -*- */

// ========================================================================
// $Id$
// 
// = LIBRARY
//    orbsvcs
// 
// = FILENAME
//   Link.h
//
// = AUTHOR
//    Marina Spivak <marina@cs.wustl.edu>,
//    Irfan Pyarali <irfan@cs.wustl.edu>,
//    Seth Widoff <sbw1@cs.wustl.edu>
// 
// ========================================================================

#ifndef TAO_LINK_H
#define TAO_LINK_H

#include "Trader.h"

template <class TRADER, class MAP_LOCK_TYPE>
class TAO_Link : 
  public TAO_Trader_Components <POA_CosTrading::Link>,
  public TAO_Support_Attributes <POA_CosTrading::Link>,
  public TAO_Link_Attributes <POA_CosTrading::Link>
{
public:

  TAO_Link (TRADER &trader);

  ~TAO_Link (void);
		
  virtual void add_link (const char *name, 
			 CosTrading::Lookup_ptr target, 
			 CosTrading::FollowOption def_pass_on_follow_rule, 
			 CosTrading::FollowOption limiting_follow_rule,
			 CORBA::Environment& _env) 
    TAO_THROW_SPEC ((CORBA::SystemException,
		    CosTrading::Link::IllegalLinkName, 
		    CosTrading::Link::DuplicateLinkName, 
		    CosTrading::InvalidLookupRef, 
		    CosTrading::Link::DefaultFollowTooPermissive, 
		    CosTrading::Link::LimitingFollowTooPermissive));
  // BEGIN SPEC
  // The add_link operation allows a trader subsequently to use the
  // service of another trader in the performance of its own trading
  // service operations. 

  // The "name" parameter is used in subsequent link management
  // operations to identify the intended link. If the parameter is not
  // legally formed, then the IllegalLinkName exception is raised. An
  // exception of DuplicateLinkName is raised if the link name already
  // exists. The link name is also used as a component in a sequence
  // of name components in naming a trader for resolving or forwarding
  // operations. The sequence of context relative link names provides
  // a path to a trader.

  // The "target" parameter identifies the Lookup interface at which
  // the trading service provided by the target trader can be
  // accessed. Should the Lookup interface parameter be nil, then an
  // exception of InvalidLookupRef is raised. The target interface is
  // used to obtain the associated Register interface, which will be
  // subsequently returned as part of a describe_link operation and
  // invoked as part of a resolve operation.

  // The "def_pass_on_follow_rule" parameter specifies the default
  // link behavior for the link if no link behavior is specified on an
  // importer's query request. If the "def_pass_on_follow_rule"
  // exceeds the "limiting_follow_rule" specified in the next
  // parameter, then a DefaultFollowTooPermissive exception is
  // raised.

  // The "limiting_follow_rule" parameter specifies the most
  // permissive link follow behavior that the link is willing to
  // tolerate. The exception LimitingFollowTooPermissive is raised if
  // this parameter exceeds the trader's attribute of
  // "max_link_follow_policy" at the time of the link's creation. Note
  // it is possible for a link's "limiting_follow_rule" to exceed the
  // trader's "max_link_follow_policy" later in the life of a link, as
  // it is possible that the trader could set its
  // "max_link_follow_policy" to a more restrictive value after the
  // creation of the link. 
  // END SPEC
  
  virtual void remove_link (const char *name,
			    CORBA::Environment& _env) 
    TAO_THROW_SPEC ((CORBA::SystemException,
		    CosTrading::Link::IllegalLinkName, 
		    CosTrading::Link::UnknownLinkName));

  // BEGIN SPEC
  // The remove_link operation removes all knowledge of the target
  // trader. The target trader cannot be used subsequently to resolve,
  // forward, or propagate trading operations from this trader.

  // The "name" parameter identifies the link to be removed. The
  // exception IllegalLinkName is raised if the link is formed poorly
  // and the UnknownLinkName exception is raised if the named link is
  // not in the trader. 
  // END SPEC
  
  virtual CosTrading::Link::LinkInfo* describe_link (const char *name,
						     CORBA::Environment&) 
    TAO_THROW_SPEC ((CORBA::SystemException, 
		    CosTrading::Link::IllegalLinkName, 
		    CosTrading::Link::UnknownLinkName));

  // BEGIN SPEC
  // The describe_link operation returns information on a link held in
  // the trader.

  // The "name" parameter identifies the link whose description is
  // required. For a malformed link name, the exception
  // IllegalLinkName is raised. An UnknownLinkName exception is raised
  // if the named link is not found in the trader.

  // The operation returns a LinkInfo structure comprising: ° the
  // Lookup interface of the target trading service, ° the Register
  // interface of the target trading service, and ° the default, as
  // well as the limiting follow behavior of the named link.

  // If the target service does not support the Register interface,
  // then that field of the LinkInfo structure is nil. Given the
  // description of the Register::resolve() operation in "Resolve
  // Operation" on page 16-45, most implementations will opt for
  // determining the Register interface when add_link is called and
  // storing that information statically with the rest of the link
  // state. 
  // END SPEC
  
  virtual CosTrading::LinkNameSeq* list_links (CORBA::Environment& _env)
    TAO_THROW_SPEC ((CORBA::SystemException));

  // BEGIN SPEC
  // The list_links operation returns a list of the names of all
  // trading links within the trader. The names can be used
  // subsequently for other management operations, such as
  // describe_link or remove_link. 
  // END SPEC
  
  virtual void modify_link (const char *name, 
			    CosTrading::FollowOption def_pass_on_follow_rule, 
			    CosTrading::FollowOption limiting_follow_rule,
			    CORBA::Environment& _env) 
    TAO_THROW_SPEC ((CosTrading::Link::IllegalLinkName, 
		    CosTrading::Link::UnknownLinkName, 
		    CosTrading::Link::DefaultFollowTooPermissive, 
		    CosTrading::Link::LimitingFollowTooPermissive));

  // BEGIN SPEC
  // The modify_link operation is used to change the existing link
  // follow behaviors of an identified link. The Lookup interface
  // reference of the target trader and the name of the link cannot be
  // changed.

  // The "name" parameter identifies the link whose follow behaviors
  // are to be changed. A poorly formed "name" raises the
  // IllegalLinkName exception. An UnknownLinkName exception is raised
  // if the link name is not known to the trader.

  // The "def_pass_on_follow_rule" parameter specifies the new default
  // link behavior for this link. If the "def_pass_on_follow_rule"
  // exceeds the "limiting_follow_rule" specified in the next
  // parameter, then a DefaultFollowTooPermissive exception is
  // raised.

  // The "limiting_follow_rule" parameter specifies the new limit for
  // the follow behavior of this link. The exception
  // LimitingFollowTooPermissive is raised if the value exceeds the
  // current "max_link_follow_policy" of the trader. 
  // END SPEC
  		
private:

  typedef ACE_Hash_Map_Manager
  <
  TAO_String_Hash_Key,
  CosTrading::Link::LinkInfo,
  MAP_LOCK_TYPE
  >
  Links;
  
  Links links_;
  // The collection of link connecting this trader to others in the
  // federation. 
  
  TRADER &trader_;
};

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

#endif /* TAO_LINK_H */