1%%----------------------------------------------------------------------
2%%
3%% %CopyrightBegin%
4%%
5%% Copyright Ericsson AB 1999-2015. All Rights Reserved.
6%%
7%% Licensed under the Apache License, Version 2.0 (the "License");
8%% you may not use this file except in compliance with the License.
9%% You may obtain a copy of the License at
10%%
11%%     http://www.apache.org/licenses/LICENSE-2.0
12%%
13%% Unless required by applicable law or agreed to in writing, software
14%% distributed under the License is distributed on an "AS IS" BASIS,
15%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16%% See the License for the specific language governing permissions and
17%% limitations under the License.
18%%
19%% %CopyrightEnd%
20%%
21%%
22%%----------------------------------------------------------------------
23%% File    : CosNotification_Definitions.hrl
24%% Purpose :
25%%----------------------------------------------------------------------
26
27-ifndef(COSNOTIFICATION_DEFINITIONS_HRL).
28-define(COSNOTIFICATION_DEFINITIONS_HRL, true).
29
30%% ---------------- General comment ------------------------------------
31%% ******* README ********
32%% The prefix 'not' is short for notification, and is used to separate locally
33%% defined macros from the global ones, i.e., do NOT confuse this with a negation!!
34%%
35%% In this file you find globally used data structures, constants etc.
36%%
37
38%%--------------- INCLUDES ---------------------------------------------
39
40%%-------- Constants -------------------------------------------------
41-define(not_SupportedGrammars, ["EXTENDED_TCL"]).
42
43%% !!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
44%%
45%% If OMG redefines the values for the constants the definitions
46%% below must be redefined!!
47%%
48%% !!!!!!!!!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
49-define(not_BestEffort,            0).
50-define(not_Persistent,            1).
51-define(not_EventReliability,      "EventReliability").
52-define(not_ConnectionReliability, "ConnectionReliability").
53-define(not_Priority,              "Priority").
54-define(not_LowestPriority,        -32767).
55-define(not_HighestPriority,        32767).
56-define(not_DefaultPriority,        0).
57-define(not_StartTime,              "StartTime").
58-define(not_StopTime,               "StopTime").
59-define(not_Timeout,                "Timeout").
60-define(not_OrderPolicy,            "OrderPolicy").
61-define(not_AnyOrder,               0).
62-define(not_FifoOrder,              1).
63-define(not_PriorityOrder,          2).
64-define(not_DeadlineOrder,          3).
65-define(not_DiscardPolicy,          "DiscardPolicy").
66-define(not_LifoOrder,              4).
67-define(not_RejectNewEvents,        5).
68-define(not_MaximumBatchSize,       "MaximumBatchSize").
69-define(not_PacingInterval,         "PacingInterval").
70-define(not_StartTimeSupported,     "StartTimeSupported").
71-define(not_StopTimeSupported,      "StopTimeSupported").
72-define(not_MaxEventsPerConsumer,   "MaxEventsPerConsumer").
73-define(not_MaxQueueLength,         "MaxQueueLength").
74-define(not_MaxConsumers,           "MaxConsumers").
75-define(not_MaxSuppliers,           "MaxSuppliers").
76
77%%--------------- QOS DEFINITIONS ----------------------------
78%% Limits for QoS. These are our own limits.
79-define(not_MaxBatchSize,      10000).
80-define(not_MinBatchSize,      1).
81-define(not_MinTimeout,        0).
82-define(not_MaxTimeout,        100000000000).
83-define(not_MinPacing,         0).
84-define(not_MaxPacing,         100000000000).
85-define(not_MinConsumerEvents, 1).
86-define(not_MaxConsumerEvents, 10000).
87
88-define(not_QOS_LIMITS,
89[#'CosNotification_NamedPropertyRange'
90 {name=?not_EventReliability,
91  range=
92  #'CosNotification_PropertyRange'{
93    low_val=any:create(orber_tc:short(), ?not_BestEffort),
94    high_val=any:create(orber_tc:short(), ?not_Persistent)
95   }},
96 #'CosNotification_NamedPropertyRange'
97 {name=?not_ConnectionReliability,
98  range=
99  #'CosNotification_PropertyRange'{
100    low_val=any:create(orber_tc:short(), ?not_BestEffort),
101    high_val=any:create(orber_tc:short(), ?not_Persistent)
102   }},
103 #'CosNotification_NamedPropertyRange'
104 {name=?not_Priority,
105  range=
106  #'CosNotification_PropertyRange'{
107    low_val=any:create(orber_tc:short(), ?not_LowestPriority),
108    high_val=any:create(orber_tc:short(), ?not_HighestPriority)
109   }},
110 #'CosNotification_NamedPropertyRange'
111 {name=?not_StartTimeSupported,
112  range=
113  #'CosNotification_PropertyRange'{
114    low_val=any:create(orber_tc:boolean(), false),
115    high_val=any:create(orber_tc:boolean(), true)
116   }},
117 #'CosNotification_NamedPropertyRange'
118 {name=?not_StopTimeSupported,
119  range=
120  #'CosNotification_PropertyRange'{
121    low_val=any:create(orber_tc:boolean(), false),
122    high_val=any:create(orber_tc:boolean(), true)
123   }},
124 #'CosNotification_NamedPropertyRange'
125 {name=?not_Timeout,
126  range=
127  #'CosNotification_PropertyRange'{
128    low_val=any:create(orber_tc:unsigned_long_long(), ?not_MinTimeout),
129    high_val=any:create(orber_tc:unsigned_long_long(), ?not_MaxTimeout)
130   }},
131 #'CosNotification_NamedPropertyRange'
132 {name=?not_OrderPolicy,
133  range=
134  #'CosNotification_PropertyRange'{
135    low_val=any:create(orber_tc:short(), ?not_AnyOrder),
136    high_val=any:create(orber_tc:short(), ?not_PriorityOrder)
137   }},
138 #'CosNotification_NamedPropertyRange'
139 {name=?not_DiscardPolicy,
140  range=
141  #'CosNotification_PropertyRange'{
142    low_val=any:create(orber_tc:short(), ?not_AnyOrder),
143    high_val=any:create(orber_tc:short(), ?not_PriorityOrder)
144   }},
145 #'CosNotification_NamedPropertyRange'
146 {name=?not_MaximumBatchSize,
147  range=
148  #'CosNotification_PropertyRange'{
149    low_val=any:create(orber_tc:long(), ?not_MinBatchSize),
150    high_val=any:create(orber_tc:long(), ?not_MaxBatchSize)
151   }},
152 #'CosNotification_NamedPropertyRange'
153 {name=?not_PacingInterval,
154  range=
155  #'CosNotification_PropertyRange'{
156    low_val=any:create(orber_tc:unsigned_long_long(), ?not_MinPacing),
157    high_val=any:create(orber_tc:unsigned_long_long(), ?not_MaxPacing)
158   }},
159 #'CosNotification_NamedPropertyRange'
160 {name=?not_MaxEventsPerConsumer,
161  range=
162  #'CosNotification_PropertyRange'{
163    low_val=any:create(orber_tc:long(), ?not_MinConsumerEvents),
164    high_val=any:create(orber_tc:long(), ?not_MaxConsumerEvents)
165   }}
166]).
167
168
169
170%% Local record used internally, and the reason for this is we get faster
171%% access to QoS settings.
172-record(qos, {'EventReliability',
173	      'ConnectionReliability',
174	      'Priority',
175	      'StartTimeSupported',
176	      'StopTimeSupported',
177	      'Timeout',
178	      'OrderPolicy',
179	      'DiscardPolicy',
180	      'MaximumBatchSize',
181	      'PacingInterval',
182	      'MaxEventsPerConsumer'}).
183
184%% Global (OMG) representation of QoS.
185-define(not_DEFAULT_QOS,
186[#'CosNotification_Property'{name=?not_MaximumBatchSize,
187			     value=any:create(orber_tc:long(), 1)},
188 #'CosNotification_Property'{name=?not_PacingInterval,
189			     value=any:create(orber_tc:unsigned_long_long(), 0)},
190 #'CosNotification_Property'{name=?not_Timeout,
191			     value=any:create(orber_tc:unsigned_long_long(), 0)},
192 #'CosNotification_Property'{name=?not_MaxEventsPerConsumer,
193			     value=any:create(orber_tc:long(), 100)},
194 #'CosNotification_Property'{name=?not_OrderPolicy,
195			     value=any:create(orber_tc:short(),
196					      ?not_PriorityOrder)},
197 #'CosNotification_Property'{name=?not_EventReliability,
198			     value=any:create(orber_tc:short(),
199					      ?not_BestEffort)},
200 #'CosNotification_Property'{name=?not_ConnectionReliability,
201			     value=any:create(orber_tc:short(),
202					      ?not_BestEffort)},
203 #'CosNotification_Property'{name=?not_DiscardPolicy,
204			     value=any:create(orber_tc:short(),
205					      ?not_RejectNewEvents)},
206 #'CosNotification_Property'{name=?not_StartTimeSupported,
207			     value=any:create(orber_tc:boolean(), false)},
208 #'CosNotification_Property'{name=?not_StopTimeSupported,
209			     value=any:create(orber_tc:boolean(), false)},
210 #'CosNotification_Property'{name=?not_Priority,
211			     value=any:create(orber_tc:short(), ?not_DefaultPriority)}]).
212
213%%--------------- QOS CREATORS -------------------------------
214-define(not_CreateInitQoS(), #qos{}).
215
216%%--------------- QOS DESTRUCTORS ----------------------------
217-define(not_DestroyQoS(Q), ok).
218
219%%--------------- QOS SELECTORS ------------------------------
220-define(not_GetEventReliability(Q),        Q#qos.'EventReliability').
221-define(not_GetConnectionReliability(Q),   Q#qos.'ConnectionReliability').
222-define(not_GetPriority(Q),                Q#qos.'Priority').
223-define(not_GetStartTimeSupported(Q),      Q#qos.'StartTimeSupported').
224-define(not_GetStopTimeSupported(Q),       Q#qos.'StopTimeSupported').
225-define(not_GetTimeout(Q),                 Q#qos.'Timeout').
226-define(not_GetOrderPolicy(Q),             Q#qos.'OrderPolicy').
227-define(not_GetDiscardPolicy(Q),           Q#qos.'DiscardPolicy').
228-define(not_GetMaximumBatchSize(Q),        Q#qos.'MaximumBatchSize').
229-define(not_GetPacingInterval(Q),          Q#qos.'PacingInterval').
230-define(not_GetMaxEventsPerConsumer(Q),    Q#qos.'MaxEventsPerConsumer').
231
232%%--------------- QOS MODIFIERS ------------------------------
233-define(not_SetEventReliability(Q,D),      Q#qos{'EventReliability'=D}).
234-define(not_SetConnectionReliability(Q,D), Q#qos{'ConnectionReliability'=D}).
235-define(not_SetPriority(Q,D),              Q#qos{'Priority'=D}).
236-define(not_SetStartTimeSupported(Q,D),    Q#qos{'StartTimeSupported'=D}).
237-define(not_SetStopTimeSupported(Q,D),     Q#qos{'StopTimeSupported'=D}).
238-define(not_SetTimeout(Q,D),               Q#qos{'Timeout'=D}).
239-define(not_SetOrderPolicy(Q,D),           Q#qos{'OrderPolicy'=D}).
240-define(not_SetDiscardPolicy(Q,D),         Q#qos{'DiscardPolicy'=D}).
241-define(not_SetMaximumBatchSize(Q,D),      Q#qos{'MaximumBatchSize'=D}).
242-define(not_SetPacingInterval(Q,D),        Q#qos{'PacingInterval'=D}).
243-define(not_SetMaxEventsPerConsumer(Q,D),  Q#qos{'MaxEventsPerConsumer'=D}).
244
245%%--------------- StructuredEvent CREATORS -------------------
246-define(not_CreateSE(StrD,StrT,StrE,PSeqV,PSeqF,AnyR),
247#'CosNotification_StructuredEvent'{header =
248   #'CosNotification_EventHeader'{fixed_header =
249		  #'CosNotification_FixedEventHeader'{event_type =
250				      #'CosNotification_EventType'{domain_name=StrD,
251						   type_name=StrT},
252				      event_name = StrE},
253		  variable_header = PSeqV},
254   filterable_data = PSeqF,
255   remainder_of_body = AnyR}).
256%% Can be used in guards.
257-define(not_isConvertedAny(E),
258	(((E#'CosNotification_StructuredEvent'.header)
259	  #'CosNotification_EventHeader'.fixed_header)
260	 #'CosNotification_FixedEventHeader'.event_type)
261	#'CosNotification_EventType'.type_name == "%ANY").
262%% Can NOT be used in guards!!!!!
263-define(not_isConvertedStructured(E),
264	any:get_typecode(E) == 'CosNotification_StructuredEvent':tc()).
265
266%%--------------- StructuredEvent DESTRUCTORS ----------------
267-define(not_DestroySE(E), ok).
268
269%%--------------- StructuredEvent SELECTORS ------------------
270-define(not_GetSEHeader(E), E#'StructuredEvent'.header).
271-define(not_GetSEFixedHeader(E), E#'StructuredEvent'.header).
272
273%%--------------- StructuredEvent MODIFIERS ------------------
274
275%%-------- QoS support -----------------------------------------------
276-define(not_SUPPORTED_QOS,
277[{?not_EventReliability,      'EventReliability'},
278 {?not_ConnectionReliability, 'ConnectionReliability'},
279 {?not_Priority,              'Priority'},
280 {?not_StartTimeSupported,    'StartTimeSupported'},
281 {?not_StopTimeSupported,     'StopTimeSupported'},
282 {?not_Timeout,               'Timeout'},
283 {?not_OrderPolicy,           'OrderPolicy'},
284 {?not_DiscardPolicy,         'DiscardPolicy'},
285 {?not_MaximumBatchSize,      'MaximumBatchSize'},
286 {?not_PacingInterval,        'PacingInterval'},
287 {?not_MaxEventsPerConsumer,  'MaxEventsPerConsumer'}]).
288
289%%-------- ADMINPROPERTIESADMIN --------------------------------------
290
291%% According to the OMG TC Document telecom/98-11-01, p 63 (section 2.5.7), the
292%% default-value for these 3 admin properties is zero, which means that no limit
293%% applies to that property.
294-define(not_DEFAULT_ADMINPROPERTIES,
295[#'CosNotification_Property'{name=?not_MaxQueueLength,
296			     value=any:create(orber_tc:long(), 0)},
297 #'CosNotification_Property'{name=?not_MaxConsumers,
298			     value=any:create(orber_tc:long(), 0)},
299 #'CosNotification_Property'{name=?not_MaxSuppliers,
300			     value=any:create(orber_tc:long(), 0)}]).
301
302-define(not_SUPPORTED_ADMINPROPERTIES,
303[{?not_MaxQueueLength, 'MaxQueueLength'},
304 {?not_MaxConsumers, 'MaxConsumers'},
305 {?not_MaxSuppliers, 'MaxSuppliers'}]).
306
307
308%%-------- MISC --------------------------------------------------------
309
310-define(not_DEFAULT_SETTINGS, [{pullInterval, 20},
311			       {filterOp, 'OR_OP'},
312			       {gcTime, 60},
313			       {gcLimit, 50},
314			       {timeService, undefined},
315			       {typecheck, true},
316			       {tty, false},
317			       {logfile, false},
318			       {server_options, []}]).
319-define(not_CreateDBKey, term_to_binary({{erlang:system_time(),
320					  erlang:unique_integer()},
321					node()})).
322
323-define(DEBUG_LEVEL, 3).
324
325-ifdef(debug).
326
327-define(debug_print(F,A), io:format("[~p(~p)] "++F,[?MODULE, ?LINE]++A)).
328-define(DBG(F,A), io:format("[~p(~p)] "++F,[?MODULE, ?LINE]++A)).
329-define(not_TypeCheck(O,I), ok).
330%-define(not_TypeCheck(O,M), 'CosNotification_Common':type_check(O,M)).
331
332-else.
333
334-define(debug_print(F,A), ok).
335-define(DBG(F,A), ok).
336-define(not_TypeCheck(O,I), ok).
337
338-endif.
339
340
341
342-endif.
343%%--------------- END OF MODULE ------------------------------
344