aboutsummaryrefslogtreecommitdiffstats
path: root/lib/cosEventDomain/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cosEventDomain/src')
-rw-r--r--lib/cosEventDomain/src/CosEventDomainAdmin.cfg4
-rw-r--r--lib/cosEventDomain/src/CosEventDomainAdmin.idl280
-rw-r--r--lib/cosEventDomain/src/CosEventDomainAdmin_EventDomainFactory_impl.erl182
-rw-r--r--lib/cosEventDomain/src/CosEventDomainAdmin_EventDomain_impl.erl1415
-rw-r--r--lib/cosEventDomain/src/Makefile179
-rw-r--r--lib/cosEventDomain/src/cosEventDomain.app.src31
-rw-r--r--lib/cosEventDomain/src/cosEventDomain.appup.src6
-rw-r--r--lib/cosEventDomain/src/cosEventDomainApp.erl363
-rw-r--r--lib/cosEventDomain/src/cosEventDomainApp.hrl69
9 files changed, 2529 insertions, 0 deletions
diff --git a/lib/cosEventDomain/src/CosEventDomainAdmin.cfg b/lib/cosEventDomain/src/CosEventDomainAdmin.cfg
new file mode 100644
index 0000000000..75a2720088
--- /dev/null
+++ b/lib/cosEventDomain/src/CosEventDomainAdmin.cfg
@@ -0,0 +1,4 @@
+{this, "CosEventDomainAdmin::EventDomain"}.
+{{handle_info, "CosEventDomainAdmin::EventDomain"}, true}.
+{this, "CosEventDomainAdmin::EventDomainFactory"}.
+{{handle_info, "CosEventDomainAdmin::EventDomainFactory"}, true}.
diff --git a/lib/cosEventDomain/src/CosEventDomainAdmin.idl b/lib/cosEventDomain/src/CosEventDomainAdmin.idl
new file mode 100644
index 0000000000..2ecd935c67
--- /dev/null
+++ b/lib/cosEventDomain/src/CosEventDomainAdmin.idl
@@ -0,0 +1,280 @@
+#ifndef _COS_EVENT_DOMAIN_ADMIN_IDL_
+#define _COS_EVENT_DOMAIN_ADMIN_IDL_
+
+#pragma prefix "omg.org"
+
+// Event Domain Interface
+#include "CosNotification.idl"
+#include "CosEventComm.idl"
+#include "CosNotifyComm.idl"
+#include "CosNotifyChannelAdmin.idl"
+
+
+module CosEventDomainAdmin {
+
+ // The following constant declarations define the Event Domain
+ // QoS property names and the associated values each property can
+ // take on. The name/value pairs for each Event Domain property
+ // are grouped, beginning with a string constant defined for the
+ // property name, followed by the values the property can take on.
+
+ const string CycleDetection = "CycleDetection";
+ const short AuthorizeCycles = 0; // Default value
+ const short ForbidCycles = 1;
+
+ const string DiamondDetection = "DiamondDetection";
+ const short AuthorizeDiamonds = 0; // Default value
+ const short ForbidDiamonds = 1;
+
+
+ // The following enum declaration defines the types that a channel
+ // can be of. It is used to specify channel types while externalizing
+ // and instantiating topologies.
+ enum ChannelType
+ {
+ CHANNEL,
+ TYPED_CHANNEL,
+ LOG_CHANNEL,
+ TYPED_LOG_CHANNEL
+ };
+
+ enum NotificationStyle {
+ Push,
+ Pull
+ };
+
+ typedef long MemberID;
+ typedef sequence <MemberID> MemberIDSeq;
+ typedef long ConnectionID;
+ typedef sequence <ConnectionID> ConnectionIDSeq;
+
+ struct Connection {
+ MemberID supplier_id;
+ MemberID consumer_id;
+ CosNotifyChannelAdmin::ClientType ctype;
+ NotificationStyle notification_style;
+ };
+
+
+ typedef MemberIDSeq Route;
+ typedef sequence<Route> RouteSeq;
+
+ typedef Route Cycle;
+ typedef sequence<Cycle> CycleSeq;
+
+ typedef RouteSeq Diamond;
+ typedef sequence<Diamond> DiamondSeq;
+
+ exception CycleCreationForbidden
+ {
+ Cycle cyc;
+ };
+
+ exception DiamondCreationForbidden
+ {
+ Diamond diam;
+ };
+
+ // Forward declarations
+ interface ConsumerAdmin;
+ interface SupplierAdmin;
+
+
+ typedef long DomainID;
+ typedef sequence <DomainID> DomainIDSeq;
+ typedef long ItemID;
+
+
+ // EventDomain administrates EventChannels that reside in the same
+ // administrative domain
+ exception ConnectionNotFound {};
+ exception AlreadyExists {};
+
+
+ interface EventDomain :
+ CosNotification::QoSAdmin ,
+ CosNotification::AdminPropertiesAdmin {
+
+ MemberID add_channel ( in CosNotifyChannelAdmin::EventChannel channel );
+
+ MemberIDSeq get_all_channels ();
+
+ CosNotifyChannelAdmin::EventChannel get_channel ( in MemberID channel )
+ raises ( CosNotifyChannelAdmin::ChannelNotFound );
+
+ void remove_channel ( in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ ConnectionID add_connection ( in Connection connection)
+ raises (CosNotifyChannelAdmin::ChannelNotFound,
+ CosEventChannelAdmin::TypeError,
+ AlreadyExists,
+ CycleCreationForbidden,
+ DiamondCreationForbidden);
+
+ ConnectionIDSeq get_all_connections ();
+
+ Connection get_connection ( in ConnectionID connection )
+ raises ( ConnectionNotFound );
+
+ void remove_connection ( in ConnectionID connection )
+ raises ( ConnectionNotFound );
+
+ CosNotifyChannelAdmin::ChannelIDSeq get_offer_channels ( in MemberID channel )
+ raises ( CosNotifyChannelAdmin::ChannelNotFound );
+
+ CosNotifyChannelAdmin::ChannelIDSeq get_subscription_channels ( in MemberID channel )
+ raises ( CosNotifyChannelAdmin::ChannelNotFound );
+
+ void destroy();
+
+ // Cycle and diamond configurations listing
+ CycleSeq get_cycles();
+
+ DiamondSeq get_diamonds();
+
+
+ // Connection of clients to the domain
+ // - using no specific information
+ // - for any clients
+ void set_default_consumer_channel(in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ void set_default_supplier_channel(in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::ProxyPushSupplier
+ connect_push_consumer(in CosEventComm::PushConsumer client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::ProxyPullSupplier
+ connect_pull_consumer(in CosEventComm::PullConsumer client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::ProxyPushConsumer
+ connect_push_supplier(in CosEventComm::PushSupplier client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::ProxyPullConsumer
+ connect_pull_supplier(in CosEventComm::PullSupplier client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ // - for structured clients
+ CosNotifyChannelAdmin::StructuredProxyPushSupplier
+ connect_structured_push_consumer(in CosNotifyComm::StructuredPushConsumer client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::StructuredProxyPullSupplier
+ connect_structured_pull_consumer(in CosNotifyComm::StructuredPullConsumer client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::StructuredProxyPushConsumer
+ connect_structured_push_supplier(in CosNotifyComm::StructuredPushSupplier client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::StructuredProxyPullConsumer
+ connect_structured_pull_supplier(in CosNotifyComm::StructuredPullSupplier client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ // - for sequence clients
+ CosNotifyChannelAdmin::SequenceProxyPushSupplier
+ connect_sequence_push_consumer(in CosNotifyComm::SequencePushConsumer client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::SequenceProxyPullSupplier
+ connect_sequence_pull_consumer(in CosNotifyComm::SequencePullConsumer client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::SequenceProxyPushConsumer
+ connect_sequence_push_supplier(in CosNotifyComm::SequencePushSupplier client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::SequenceProxyPullConsumer
+ connect_sequence_pull_supplier(in CosNotifyComm::SequencePullSupplier client)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ // - using a channel id
+ // - for any clients
+ CosNotifyChannelAdmin::ProxyPushSupplier
+ connect_push_consumer_with_id(in CosEventComm::PushConsumer client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::ProxyPullSupplier
+ connect_pull_consumer_with_id(in CosEventComm::PullConsumer client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::ProxyPushConsumer
+ connect_push_supplier_with_id(in CosEventComm::PushSupplier client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::ProxyPullConsumer
+ connect_pull_supplier_with_id(in CosEventComm::PullSupplier client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ // - for structured clients
+ CosNotifyChannelAdmin::StructuredProxyPushSupplier
+ connect_structured_push_consumer_with_id(in CosNotifyComm::StructuredPushConsumer client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::StructuredProxyPullSupplier
+ connect_structured_pull_consumer_with_id(in CosNotifyComm::StructuredPullConsumer client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::StructuredProxyPushConsumer
+ connect_structured_push_supplier_with_id(in CosNotifyComm::StructuredPushSupplier client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::StructuredProxyPullConsumer
+ connect_structured_pull_supplier_with_id(in CosNotifyComm::StructuredPullSupplier client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ // - for sequence clients
+ CosNotifyChannelAdmin::SequenceProxyPushSupplier
+ connect_sequence_push_consumer_with_id(in CosNotifyComm::SequencePushConsumer client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::SequenceProxyPullSupplier
+ connect_sequence_pull_consumer_with_id(in CosNotifyComm::SequencePullConsumer client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::SequenceProxyPushConsumer
+ connect_sequence_push_supplier_with_id(in CosNotifyComm::SequencePushSupplier client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+
+ CosNotifyChannelAdmin::SequenceProxyPullConsumer
+ connect_sequence_pull_supplier_with_id(in CosNotifyComm::SequencePullSupplier client,
+ in MemberID channel)
+ raises (CosNotifyChannelAdmin::ChannelNotFound);
+ };
+
+ exception DomainNotFound {};
+
+ interface EventDomainFactory {
+
+ EventDomain create_event_domain( in CosNotification::QoSProperties initialQoS ,
+ in CosNotification::AdminProperties initialAdmin,
+ out DomainID id )
+ raises ( CosNotification::UnsupportedQoS,
+ CosNotification::UnsupportedAdmin );
+
+ DomainIDSeq get_all_domains ();
+
+ EventDomain get_event_domain (
+ in DomainID id )
+ raises ( DomainNotFound );
+ };
+};
+
+#endif // _COS_EVENT_DOMAIN_ADMIN_IDL_
+
diff --git a/lib/cosEventDomain/src/CosEventDomainAdmin_EventDomainFactory_impl.erl b/lib/cosEventDomain/src/CosEventDomainAdmin_EventDomainFactory_impl.erl
new file mode 100644
index 0000000000..1729402026
--- /dev/null
+++ b/lib/cosEventDomain/src/CosEventDomainAdmin_EventDomainFactory_impl.erl
@@ -0,0 +1,182 @@
+%%--------------------------------------------------------------------
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+%%----------------------------------------------------------------------
+%% File : CosEventDomainAdmin_EventDomainFactory_impl.erl
+%% Description :
+%%
+%%----------------------------------------------------------------------
+-module('CosEventDomainAdmin_EventDomainFactory_impl').
+
+%%----------------------------------------------------------------------
+%% Include files
+%%----------------------------------------------------------------------
+-include_lib("orber/include/corba.hrl").
+-include_lib("orber/include/ifr_types.hrl").
+-include_lib("cosNotification/include/CosNotification.hrl").
+
+-include("CosEventDomainAdmin.hrl").
+-include("cosEventDomainApp.hrl").
+
+%%----------------------------------------------------------------------
+%% External exports
+%%----------------------------------------------------------------------
+-export([init/1,
+ terminate/2,
+ code_change/3,
+ handle_info/2]).
+
+-export([create_event_domain/4,
+ get_all_domains/2,
+ get_event_domain/3]).
+
+%%----------------------------------------------------------------------
+%% Internal exports
+%%----------------------------------------------------------------------
+-export([]).
+
+%%----------------------------------------------------------------------
+%% Records
+%%----------------------------------------------------------------------
+-record(state, {current_id = -1, domains = []}).
+
+%%----------------------------------------------------------------------
+%% Macros
+%%----------------------------------------------------------------------
+
+%%======================================================================
+%% External functions
+%%======================================================================
+%%----------------------------------------------------------------------
+%% Function : init/1
+%% Returns : {ok, State} |
+%% {ok, State, Timeout} |
+%% ignore |
+%% {stop, Reason}
+%% Description: Initiates the server
+%%----------------------------------------------------------------------
+init([]) ->
+ process_flag(trap_exit, true),
+ {ok, #state{}}.
+
+%%----------------------------------------------------------------------
+%% Function : terminate/2
+%% Returns : any (ignored by gen_server)
+%% Description: Shutdown the server
+%%----------------------------------------------------------------------
+terminate(_Reason, _State) ->
+ ok.
+
+%%----------------------------------------------------------------------
+%% Function : code_change/3
+%% Returns : {ok, NewState}
+%% Description: Convert process state when code is changed
+%%----------------------------------------------------------------------
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+
+%%----------------------------------------------------------------------
+%% Function : handle_info/2
+%% Returns : {noreply, State} |
+%% {stop, Reason, State}
+%% Description: Handle, for example, exit signals.
+%%----------------------------------------------------------------------
+handle_info({'EXIT', Pid, _Reason}, State) ->
+ {noreply, State#state{domains=delete_domain(State#state.domains, Pid, [])}};
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+
+%%----------------------------------------------------------------------
+%% Function : create_event_domain
+%% Arguments : InitialQoS - CosNotification::QoSProperties
+%% InitialAdmin - CosNotification::AdminProperties
+%% Returns : CosEventDomainAdmin::EventDomain |
+%% {'EXCEPTION', #'CosNotification_UnsupportedQoS'{}} |
+%% {'EXCEPTION', #'CosNotification_UnsupportedAdmin'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+create_event_domain(_OE_This, State, InitialQoS, InitialAdmin) ->
+ Id = cosEventDomainApp:create_id(State#state.current_id),
+ Admin = cosEventDomainApp:get_admin(InitialAdmin),
+ QoS = cosEventDomainApp:get_qos(InitialQoS),
+ case catch 'CosEventDomainAdmin_EventDomain':oe_create_link([self(), Id,
+ QoS, Admin],
+ [{sup_child, true}]) of
+ {ok, Pid, ED} ->
+ {reply, {ED, Id}, State#state{current_id = Id,
+ domains = [{Id, ED, Pid}|State#state.domains]}};
+ What ->
+ orber:dbg("[~p] CosEventDomainAdmin_EventDomainFactory:"
+ "create_event_domain();~n"
+ "Failed creatin a new EventDomain due to: ~p",
+ [?LINE, What], ?DEBUG_LEVEL),
+ corba:raise(#'INTERNAL'{completion_status=?COMPLETED_NO})
+ end.
+
+%%----------------------------------------------------------------------
+%% Function : get_all_domains
+%% Arguments : -
+%% Returns : CosEventDomainAdmin::DomainIDSeq - [long()]
+%% Description:
+%%----------------------------------------------------------------------
+get_all_domains(_OE_This, State) ->
+ {reply, get_all_domains_helper(State#state.domains, []), State}.
+
+get_all_domains_helper([], Acc) ->
+ Acc;
+get_all_domains_helper([{Id, _, _}|T], Acc) ->
+ get_all_domains_helper(T, [Id|Acc]).
+
+
+%%----------------------------------------------------------------------
+%% Function : get_event_domain
+%% Arguments : CosEventDomainAdmin::DomainID - long()
+%% Returns : CosEventDomainAdmin::EventDomain |
+%% {'EXCEPTION', #'CosEventDomainAdmin_DomainNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+get_event_domain(_OE_This, State, DomainID) ->
+ {reply, get_event_domain_helper(State#state.domains, DomainID), State}.
+
+get_event_domain_helper([], _) ->
+ corba:raise(#'CosEventDomainAdmin_DomainNotFound'{});
+get_event_domain_helper([{Id, ED, _}|_], Id) ->
+ ED;
+get_event_domain_helper([_|T], Id) ->
+ get_event_domain_helper(T, Id).
+
+%%======================================================================
+%% Internal functions
+%%======================================================================
+delete_domain([], _, Acc) ->
+ %% The domain didn't exist.
+ Acc;
+delete_domain([{_Id, _, Pid}], Pid, Acc) ->
+ Acc;
+delete_domain([{_Id, _, Pid}|T], Pid, Acc) ->
+ T++Acc;
+delete_domain([H|T], Pid, Acc) ->
+ delete_domain(T, Pid, [H|Acc]).
+
+%%======================================================================
+%% END OF MODULE
+%%======================================================================
+
diff --git a/lib/cosEventDomain/src/CosEventDomainAdmin_EventDomain_impl.erl b/lib/cosEventDomain/src/CosEventDomainAdmin_EventDomain_impl.erl
new file mode 100644
index 0000000000..0b73100540
--- /dev/null
+++ b/lib/cosEventDomain/src/CosEventDomainAdmin_EventDomain_impl.erl
@@ -0,0 +1,1415 @@
+%%--------------------------------------------------------------------
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+%%----------------------------------------------------------------------
+%% File : CosEventDomainAdmin_EventDomain_impl.erl
+%% Description :
+%%
+%%----------------------------------------------------------------------
+-module('CosEventDomainAdmin_EventDomain_impl').
+
+%%----------------------------------------------------------------------
+%% Include files
+%%----------------------------------------------------------------------
+-include_lib("orber/include/corba.hrl").
+-include_lib("orber/include/ifr_types.hrl").
+-include_lib("cosNotification/include/CosNotifyChannelAdmin.hrl").
+-include_lib("cosNotification/include/CosNotification.hrl").
+
+-include("cosEventDomainApp.hrl").
+-include("CosEventDomainAdmin.hrl").
+
+%%----------------------------------------------------------------------
+%% External exports
+%%----------------------------------------------------------------------
+-export([init/1,
+ terminate/2,
+ code_change/3,
+ handle_info/2]).
+
+%%------------------ CosEventDomainAdmin::EventDomain ------------------
+-export([add_channel/3,
+ get_all_channels/2,
+ get_channel/3,
+ remove_channel/3,
+ add_connection/3,
+ get_all_connections/2,
+ get_connection/3,
+ remove_connection/3,
+ get_offer_channels/3,
+ get_subscription_channels/3,
+ destroy/2,
+ get_cycles/2,
+ get_diamonds/2,
+ set_default_consumer_channel/3,
+ set_default_supplier_channel/3,
+ connect_push_consumer/3,
+ connect_pull_consumer/3,
+ connect_push_supplier/3,
+ connect_pull_supplier/3,
+ connect_structured_push_consumer/3,
+ connect_structured_pull_consumer/3,
+ connect_structured_push_supplier/3,
+ connect_structured_pull_supplier/3,
+ connect_sequence_push_consumer/3,
+ connect_sequence_pull_consumer/3,
+ connect_sequence_push_supplier/3,
+ connect_sequence_pull_supplier/3,
+ connect_push_consumer_with_id/4,
+ connect_pull_consumer_with_id/4,
+ connect_push_supplier_with_id/4,
+ connect_pull_supplier_with_id/4,
+ connect_structured_push_consumer_with_id/4,
+ connect_structured_pull_consumer_with_id/4,
+ connect_structured_push_supplier_with_id/4,
+ connect_structured_pull_supplier_with_id/4,
+ connect_sequence_push_consumer_with_id/4,
+ connect_sequence_pull_consumer_with_id/4,
+ connect_sequence_push_supplier_with_id/4,
+ connect_sequence_pull_supplier_with_id/4]).
+
+%%------------------ CosNotification::QoSAdmin -------------------------
+-export([get_qos/2,
+ set_qos/3,
+ validate_qos/3]).
+
+%%------------------ CosNotification::AdminPropertiesAdmin -------------
+-export([get_admin/2,
+ set_admin/3]).
+
+
+
+%%----------------------------------------------------------------------
+%% Internal exports
+%%----------------------------------------------------------------------
+-export([]).
+
+%%----------------------------------------------------------------------
+%% Records
+%%----------------------------------------------------------------------
+-record(state, {parent_pid, id, graph, ch_counter=-1,
+ co_counter=-1, def_supplier, def_consumer, diamonds, cyclic}).
+
+-record(connection, {supplier, consumer, data}).
+
+%%----------------------------------------------------------------------
+%% Macros
+%%----------------------------------------------------------------------
+
+%%======================================================================
+%% External functions
+%%======================================================================
+%%----------------------------------------------------------------------
+%% Function : init/1
+%% Returns : {ok, State} |
+%% {ok, State, Timeout} |
+%% ignore |
+%% {stop, Reason}
+%% Description: Initiates the server
+%%----------------------------------------------------------------------
+init([ParentPid, MyId, QoS, _Admin]) ->
+ process_flag(trap_exit, true),
+ Diamonds = case lists:keysearch(?DiamondDetection, 1, QoS) of
+ false ->
+ ?ForbidDiamonds;
+ {value, {_, Value}} ->
+ Value
+ end,
+ case lists:keysearch(?CycleDetection, 1, QoS) of
+ {value, {_, ?AuthorizeCycles}} ->
+ {ok, #state{parent_pid = ParentPid, id = MyId,
+ graph = digraph:new([private]),
+ diamonds = Diamonds, cyclic = ?AuthorizeCycles}};
+ _ ->
+ {ok, #state{parent_pid = ParentPid, id = MyId,
+ graph = digraph:new([acyclic, private]),
+ diamonds = Diamonds, cyclic = ?ForbidCycles}}
+ end.
+
+%%----------------------------------------------------------------------
+%% Function : terminate/2
+%% Returns : any (ignored by gen_server)
+%% Description: Shutdown the server
+%%----------------------------------------------------------------------
+terminate(_Reason, #state{graph = DG} = _State) ->
+ Connections = digraph:edges(DG),
+ close_connections(DG, Connections),
+ digraph:delete(DG),
+ ok.
+
+%%----------------------------------------------------------------------
+%% Function : code_change/3
+%% Returns : {ok, NewState}
+%% Description: Convert process state when code is changed
+%%----------------------------------------------------------------------
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+
+%%----------------------------------------------------------------------
+%% Function : handle_info/2
+%% Returns : {noreply, State} |
+%% {stop, Reason, State}
+%% Description: Handle, for example, exit signals.
+%%----------------------------------------------------------------------
+handle_info({'EXIT', Pid, Reason}, #state{parent_pid = Pid} = State) ->
+ {stop, Reason, State};
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+%%----------------------------------------------------------------------
+%%------------------ CosEventDomainAdmin::EventDomain ------------------
+%%---------------------------------------------------------------------%
+%% Function : add_channel
+%% Arguments : Channel - CosNotifyChannelAdmin::EventChannel
+%% Returns : MemberId - long()
+%% Description:
+%%----------------------------------------------------------------------
+add_channel(_OE_This, #state{ch_counter=C, graph = DG} = State, Channel) ->
+ type_check(Channel, 'CosNotifyChannelAdmin_EventChannel'),
+ Id = cosEventDomainApp:create_id(C),
+ digraph:add_vertex(DG, Id, Channel),
+ {reply, Id, State#state{ch_counter=Id}}.
+
+%%---------------------------------------------------------------------%
+%% Function : get_all_channels
+%% Arguments : -
+%% Returns : CosEventDomainAdmin::MemberIDSeq ([long()])
+%% Description:
+%%----------------------------------------------------------------------
+get_all_channels(_OE_This, #state{graph = DG} = State) ->
+ {reply, digraph:vertices(DG), State}.
+
+%%---------------------------------------------------------------------%
+%% Function : get_channel
+%% Arguments : Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::EventChannel |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}}
+%% Description:
+%%----------------------------------------------------------------------
+get_channel(_OE_This, #state{graph = DG} = State, Id) ->
+ {reply, lookup_channel(DG, Id), State}.
+
+%%---------------------------------------------------------------------%
+%% Function : remove_channel
+%% Arguments : Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : ok |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}}
+%% Description:
+%%----------------------------------------------------------------------
+remove_channel(_OE_This, #state{graph = DG} = State, Id) ->
+ lookup_channel(DG, Id),
+ close_connections(DG, digraph:edges(DG, Id)),
+ digraph:del_vertex(DG, Id),
+ {reply, ok, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : add_connection
+%% Arguments : Connection - CosEventDomainAdmin::Connection
+%% Returns : ConnectionID |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_TypeError'{}} |
+%% {'EXCEPTION', #'CosEventDomainAdmin_AlreadyExists'{}} |
+%% {'EXCEPTION', #'CosEventDomainAdmin_CycleCreationForbidden'{cyc}} |
+%% {'EXCEPTION', #'CosEventDomainAdmin_DiamondCreationForbidden'{diam}}
+%% Description:
+%%----------------------------------------------------------------------
+add_connection(_OE_This, #state{graph = DG, co_counter = C} = State,
+ Connection) when is_record(Connection,
+ 'CosEventDomainAdmin_Connection') ->
+ SId = Connection#'CosEventDomainAdmin_Connection'.supplier_id,
+ SChannel = lookup_channel(DG, SId),
+ CId = Connection#'CosEventDomainAdmin_Connection'.consumer_id,
+ CChannel = lookup_channel(DG, CId),
+ case lists:member(CId, digraph:out_neighbours(DG, SId)) of
+ false ->
+ Id = cosEventDomainApp:create_id(C),
+ %% Try to insert the new connection before we actually setup a connection.
+ %% Note that #connection is NOT complete, hence, we must update it later.
+ case digraph:add_edge(DG, Id, SId, CId, #connection{data=Connection}) of
+ {error, {bad_edge, Path}} ->
+ corba:raise(#'CosEventDomainAdmin_CycleCreationForbidden'{cyc=Path});
+ Id when State#state.diamonds == ?AuthorizeDiamonds ->
+ case catch setup_connection(Connection, SChannel, CChannel) of
+ {ok, SProxy, CProxy} ->
+ %% Now we can update the connection with complete data.
+ digraph:add_edge(DG, Id, SId, CId, #connection{supplier=SProxy,
+ consumer=CProxy,
+ data=Connection}),
+ {reply, Id, State#state{co_counter = Id}};
+ {'EXCEPTION', E} ->
+ digraph:del_edge(DG, Id),
+ corba:raise(E);
+ What ->
+ digraph:del_edge(DG, Id),
+ orber:dbg("[~p] CosEventDomainAdmin_EventDomain:"
+ "add_connection(~p);~nFailed setting up"
+ " connection due to: ~p",
+ [?LINE, Connection, What], ?DEBUG_LEVEL),
+ corba:raise(#'INTERNAL'{completion_status=?COMPLETED_MAYBE})
+ end;
+ Id ->
+ case get_diamonds_helper(State, false, SId) of
+ [] ->
+ case catch setup_connection(Connection, SChannel, CChannel) of
+ {ok, SProxy, CProxy} ->
+ %% Now we can update the connection with complete data.
+ digraph:add_edge(DG, Id, SId, CId, #connection{supplier=SProxy,
+ consumer=CProxy,
+ data=Connection}),
+ {reply, Id, State#state{co_counter = Id}};
+ {'EXCEPTION', E} ->
+ digraph:del_edge(DG, Id),
+ corba:raise(E);
+ What ->
+ digraph:del_edge(DG, Id),
+ orber:dbg("[~p] CosEventDomainAdmin_EventDomain:"
+ "add_connection(~p);~nFailed setting"
+ " up connection due to: ~p",
+ [?LINE, Connection, What],
+ ?DEBUG_LEVEL),
+ corba:raise(#'INTERNAL'{completion_status=?COMPLETED_MAYBE})
+ end;
+ Diamond ->
+ %% Since no diamonds should exist the returned list can
+ %% only describe the diamond we just created.
+ digraph:del_edge(DG, Id),
+ corba:raise(#'CosEventDomainAdmin_DiamondCreationForbidden'
+ {diam=Diamond})
+ end
+ end;
+ true ->
+ corba:raise(#'CosEventDomainAdmin_AlreadyExists'{})
+ end.
+
+
+%%---------------------------------------------------------------------%
+%% Function : get_all_connections
+%% Arguments : -
+%% Returns : CosEventDomainAdmin::ConnectionIDSeq - [long()]
+%% Description:
+%%----------------------------------------------------------------------
+get_all_connections(_OE_This, #state{graph = DG} = State) ->
+ {reply, digraph:edges(DG), State}.
+
+%%---------------------------------------------------------------------%
+%% Function : get_connection
+%% Arguments : Id - CosEventDomainAdmin::ConnectionID (long())
+%% Returns : CosEventDomainAdmin::Connection |
+%% {'EXCEPTION', #'CosEventDomainAdmin_ConnectionNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+get_connection(_OE_This, #state{graph = DG} = State, Id) ->
+ {reply, lookup_connection_data(DG, Id), State}.
+
+%%---------------------------------------------------------------------%
+%% Function : remove_connection
+%% Arguments : Id - CosEventDomainAdmin::ConnectionID (long())
+%% Returns : ok |
+%% {'EXCEPTION', #'CosEventDomainAdmin_ConnectionNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+remove_connection(_OE_This, #state{graph = DG} = State, Id) ->
+ #connection{supplier=S, consumer=C, data=Connection} =
+ lookup_connection(DG, Id),
+ close_connection(Connection, S, C),
+ digraph:del_edge(DG, Id),
+ {reply, ok, State}.
+
+
+%%---------------------------------------------------------------------%
+%% Function : get_offer_channels
+%% Arguments : Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::ChannelIDSeq |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+get_offer_channels(_OE_This, #state{graph = DG, cyclic = Cyclic} = State, Id) ->
+ lookup_channel(DG, Id),
+ case digraph:vertex(DG, Id) of
+ {Id, _Channel} when Cyclic == ?ForbidCycles ->
+ {reply, digraph_utils:reaching_neighbours([Id], DG), State};
+ {Id, _Channel} ->
+ %% If cyclic graphs is allowed 'Id' will appear in the returned list.
+ %% Hence, we must delete it.
+ {reply,lists:delete(Id, digraph_utils:reaching_neighbours([Id], DG)),
+ State};
+ false ->
+ corba:raise(#'CosNotifyChannelAdmin_ChannelNotFound'{})
+ end.
+
+%%---------------------------------------------------------------------%
+%% Function : get_subscription_channels
+%% Arguments : Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::ChannelIDSeq |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+get_subscription_channels(_OE_This, #state{graph = DG, cyclic = Cyclic} = State, Id) ->
+ lookup_channel(DG, Id),
+ case digraph:vertex(DG, Id) of
+ {Id, _Channel} when Cyclic == ?ForbidCycles ->
+ {reply, digraph_utils:reachable_neighbours([Id], DG), State};
+ {Id, _Channel} ->
+ %% If cyclic graphs is allowed 'Id' will appear in the returned list.
+ %% Hence, we must delete it.
+ {reply, lists:delete(Id, digraph_utils:reachable_neighbours([Id], DG)),
+ State};
+ false ->
+ corba:raise(#'CosNotifyChannelAdmin_ChannelNotFound'{})
+ end.
+
+%%---------------------------------------------------------------------%
+%% Function : destroy
+%% Arguments : -
+%% Returns : ok
+%% Description:
+%%----------------------------------------------------------------------
+destroy(_OE_This, #state{graph = _DG} = State) ->
+ {stop, normal, ok, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : get_cycles
+%% Arguments : -
+%% Returns : CosEventDomainAdmin::CycleSeq
+%% Description:
+%%----------------------------------------------------------------------
+get_cycles(_OE_This, #state{cyclic = ?ForbidCycles} = State) ->
+ {reply, [], State};
+get_cycles(_OE_This, #state{graph = DG} = State) ->
+ {reply, digraph_utils:cyclic_strong_components(DG), State}.
+
+%%----------------------------------------------------------------------
+%% Function : get_diamonds
+%% Arguments : -
+%% Returns : CosEventDomainAdmin::DiamondSeq
+%% Description:
+%%----------------------------------------------------------------------
+get_diamonds(_OE_This, #state{diamonds = ?ForbidDiamonds} = State) ->
+ {reply, [], State};
+get_diamonds(_OE_This, State) ->
+ {reply, get_diamonds_helper(State, true), State}.
+
+get_diamonds_helper(#state{graph = DG} = _State, FindAll) ->
+ case find_candidates(DG) of
+ {[], _, _} ->
+ [];
+ {_, [], _} ->
+ [];
+ {COut, CIn, Max} ->
+ %% In this case we cannot tell if a diamond exists. Got to
+ %% check the paths between the candidates.
+ evaluate_candidates(DG, COut, CIn, [], Max, FindAll)
+ end.
+
+get_diamonds_helper(#state{graph = DG} = _State, FindAll, Vertex) ->
+ case find_candidates(DG, Vertex) of
+ {[], _, _} ->
+ [];
+ {_, [], _} ->
+ [];
+ {COut, CIn, Max} ->
+ %% In this case we cannot tell if a diamond exists. Got to
+ %% check the paths between the candidates.
+ evaluate_candidates(DG, COut, CIn, [], Max, FindAll)
+ end.
+
+%%---------------------------------------------------------------------%
+%% Function : set_default_consumer_channel
+%% Arguments : Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : ok |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+set_default_consumer_channel(_OE_This, #state{graph = DG} = State, Id) ->
+ lookup_channel(DG, Id),
+ {reply, ok, State#state{def_consumer=Id}}.
+
+%%---------------------------------------------------------------------%
+%% Function : set_default_supplier_channel
+%% Arguments : Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : ok |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+set_default_supplier_channel(_OE_This, #state{graph = DG} = State, Id) ->
+ lookup_channel(DG, Id),
+ {reply, ok, State#state{def_supplier=Id}}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_push_consumer
+%% Arguments : PC - CosEventComm::PushConsumer
+%% Returns : CosNotifyChannelAdmin::ProxyPushSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_push_consumer(_OE_This, #state{def_supplier = Ch} = State, PC) ->
+ type_check(PC, 'CosEventComm_PushConsumer'),
+ Proxy = connect_a_push_consumer(Ch, PC, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_pull_consumer
+%% Arguments : PC - CosEventComm::PullConsumer
+%% Returns : CosNotifyChannelAdmin::ProxyPullSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_pull_consumer(_OE_This, #state{def_consumer = Ch} = State, PC) ->
+ Proxy = connect_a_pull_consumer(Ch, PC, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_push_supplier
+%% Arguments : PS - CosEventComm::PushSupplier
+%% Returns : CosNotifyChannelAdmin::ProxyPushConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_push_supplier(_OE_This, #state{def_supplier = Ch} = State, PS) ->
+ Proxy = connect_a_push_supplier(Ch, PS, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_pull_supplier
+%% Arguments : PS - CosEventComm::PullSupplier
+%% Returns : CosNotifyChannelAdmin::ProxyPullConsumer
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_pull_supplier(_OE_This, #state{def_consumer = Ch} = State, PS) ->
+ type_check(PS, 'CosEventComm_PullSupplier'),
+ Proxy = connect_a_pull_supplier(Ch, PS, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_push_consumer
+%% Arguments : PC - CosNotifyComm::StructuredPushConsumer
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPushSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_push_consumer(_OE_This, #state{def_supplier = Ch} = State, PC) ->
+ type_check(PC, 'CosNotifyComm_StructuredPushConsumer'),
+ Proxy = connect_a_push_consumer(Ch, PC, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_pull_consumer
+%% Arguments : PC - CosNotifyComm::StructuredPullConsumer
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPullSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_pull_consumer(_OE_This, #state{def_supplier = Ch} = State, PC) ->
+ Proxy = connect_a_pull_consumer(Ch, PC, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_push_supplier
+%% Arguments : PS - CosNotifyComm::StructuredPushSupplier
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPushConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_push_supplier(_OE_This, #state{def_consumer = Ch} = State, PS) ->
+ Proxy = connect_a_push_supplier(Ch, PS, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_pull_supplier
+%% Arguments : PS - CosNotifyComm::StructuredPullSupplier
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPullConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_pull_supplier(_OE_This, #state{def_consumer = Ch} = State, PS) ->
+ type_check(PS, 'CosNotifyComm_StructuredPullSupplier'),
+ Proxy = connect_a_pull_supplier(Ch, PS, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_push_consumer
+%% Arguments : PC - CosNotifyComm::SequencePushConsumer
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPushSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_push_consumer(_OE_This, #state{def_supplier = Ch} = State, PC) ->
+ type_check(PC, 'CosNotifyComm_SequencePushConsumer'),
+ Proxy = connect_a_push_consumer(Ch, PC, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_pull_consumer
+%% Arguments : PC - CosNotifyComm::SequencePullConsumer
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPullSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_pull_consumer(_OE_This, #state{def_supplier = Ch} = State, PC) ->
+ Proxy = connect_a_pull_consumer(Ch, PC, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_push_supplier
+%% Arguments : PS - CosNotifyComm::SequencePushSupplier
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPushConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_push_supplier(_OE_This, #state{def_consumer = Ch} = State, PS) ->
+ Proxy = connect_a_push_supplier(Ch, PS, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_pull_supplier
+%% Arguments : PS - CosNotifyComm::SequencePullSupplier
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPullConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_pull_supplier(_OE_This, #state{def_consumer = Ch} = State, PS) ->
+ type_check(PS, 'CosNotifyComm_SequencePullSupplier'),
+ Proxy = connect_a_pull_supplier(Ch, PS, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_push_consumer_with_id
+%% Arguments : PC - CosEventComm::PushConsumer
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::ProxyPushSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_push_consumer_with_id(_OE_This, #state{graph = DG} = State, PC, Id) ->
+ type_check(PC, 'CosEventComm_PushConsumer'),
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_push_consumer(Channel, PC, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_pull_consumer_with_id
+%% Arguments : PC - CosEventComm::PullConsumer
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::ProxyPullSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_pull_consumer_with_id(_OE_This, #state{graph = DG} = State, PC, Id) ->
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_pull_consumer(Channel, PC, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_push_supplier_with_id
+%% Arguments : PS - CosEventComm::PushSupplier
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::ProxyPushConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_push_supplier_with_id(_OE_This, #state{graph = DG} = State, PS, Id) ->
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_push_supplier(Channel, PS, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_pull_supplier_with_id
+%% Arguments : PS - CosEventComm::PullSupplier
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::ProxyPullConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_pull_supplier_with_id(_OE_This, #state{graph = DG} = State, PS, Id) ->
+ type_check(PS, 'CosEventComm_PullSupplier'),
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_pull_supplier(Channel, PS, 'ANY_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_push_consumer_with_id
+%% Arguments : PC - CosNotifyComm::StructuredPushConsumer
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPushSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_push_consumer_with_id(_OE_This, #state{graph = DG} = State, PC, Id) ->
+ type_check(PC, 'CosNotifyComm_StructuredPushConsumer'),
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_push_consumer(Channel, PC, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_pull_consumer_with_id
+%% Arguments : PC - CosNotifyComm::StructuredPullConsumer
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPullSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_pull_consumer_with_id(_OE_This, #state{graph = DG} = State, PC, Id) ->
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_pull_consumer(Channel, PC, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_push_supplier_with_id
+%% Arguments : PS - CosNotifyComm::StructuredPushSupplier
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPushConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_push_supplier_with_id(_OE_This, #state{graph = DG} = State, PS, Id) ->
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_push_supplier(Channel, PS, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_structured_pull_supplier_with_id
+%% Arguments : PS - CosNotifyComm::StructuredPullSupplier
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::StructuredProxyPullConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_structured_pull_supplier_with_id(_OE_This, #state{graph = DG} = State, PS, Id) ->
+ type_check(PS, 'CosNotifyComm_StructuredPullSupplier'),
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_pull_supplier(Channel, PS, 'STRUCTURED_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_push_consumer_with_id
+%% Arguments : PC - CosNotifyComm::SequencePushConsumer
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPushSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_push_consumer_with_id(_OE_This, #state{graph = DG} = State, PC, Id) ->
+ type_check(PC, 'CosNotifyComm_SequencePushConsumer'),
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_push_consumer(Channel, PC, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_pull_consumer_with_id
+%% Arguments : PC - CosNotifyComm::SequencePullConsumer
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPullSupplier |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_pull_consumer_with_id(_OE_This, #state{graph = DG} = State, PC, Id) ->
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_pull_consumer(Channel, PC, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_push_supplier_with_id
+%% Arguments : PS - CosNotifyComm::SequencePushSupplier
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPushConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_push_supplier_with_id(_OE_This, #state{graph = DG} = State, PS, Id) ->
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_push_supplier(Channel, PS, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+%%---------------------------------------------------------------------%
+%% Function : connect_sequence_pull_supplier_with_id
+%% Arguments : PS - CosNotifyComm::SequencePullSupplier
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::SequenceProxyPullConsumer |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}} |
+%% Description:
+%%----------------------------------------------------------------------
+connect_sequence_pull_supplier_with_id(_OE_This, #state{graph = DG} = State, PS, Id) ->
+ type_check(PS, 'CosNotifyComm_SequencePullSupplier'),
+ Channel = lookup_channel(DG, Id),
+ Proxy = connect_a_pull_supplier(Channel, PS, 'SEQUENCE_EVENT'),
+ {reply, Proxy, State}.
+
+
+%%----------------------------------------------------------------------
+%%------------------ CosNotification::QoSAdmin -------------------------
+%%---------------------------------------------------------------------%
+%% Function : get_qos
+%% Arguments : -
+%% Returns : CosNotification::QoSProperties
+%% Description:
+%%----------------------------------------------------------------------
+get_qos(_OE_This, #state{cyclic = Cyclic, diamonds = Diamonds} = State) ->
+ {reply, [#'CosNotification_Property'
+ {name = ?DiamondDetection,
+ value = any:create(orber_tc:short(), Diamonds)},
+ #'CosNotification_Property'
+ {name = ?CycleDetection,
+ value = any:create(orber_tc:short(), Cyclic)}], State}.
+
+%%---------------------------------------------------------------------%
+%% Function : set_qos
+%% Arguments : NewQoS - CosNotification::QoSProperties
+%% Returns : ok |
+%% {'EXCEPTION', #'CosNotification_UnsupportedQoS{}}
+%% Description:
+%%----------------------------------------------------------------------
+set_qos(_OE_This, State, NewQoS) ->
+ QoS = cosEventDomainApp:get_qos(NewQoS),
+ set_qos_helper(QoS, State, []).
+
+set_qos_helper([], State, []) ->
+ {reply, ok, State};
+set_qos_helper([], _, Errors) ->
+ corba:raise(#'CosNotification_UnsupportedQoS'{qos_err = Errors});
+set_qos_helper([{?DiamondDetection, Diamonds}|T], #state{diamonds = Diamonds} = State,
+ Errors) ->
+ set_qos_helper(T, State, Errors);
+set_qos_helper([{?CycleDetection, Cyclic}|T], #state{cyclic = Cyclic} = State,
+ Errors) ->
+ set_qos_helper(T, State, Errors);
+set_qos_helper([{?DiamondDetection, ?AuthorizeDiamonds}|T], State, Errors) ->
+ %% Diamonds have not been allowed so far so it's safe to allow it.
+ set_qos_helper(T, State#state{diamonds = ?AuthorizeDiamonds}, Errors);
+set_qos_helper([{?DiamondDetection, ?ForbidDiamonds}|T], State, Errors) ->
+ %% If any diamonds already exists we cannot allow this. Hence, now we must check
+ %% if we can update the QoS.
+ case get_diamonds_helper(State, false) of
+ [] ->
+ set_qos_helper(T, State#state{diamonds = ?ForbidDiamonds}, Errors);
+ _ ->
+ set_qos_helper(T, State,
+ [#'CosNotification_PropertyError'
+ {code = 'UNAVAILABLE_VALUE',
+ name = ?DiamondDetection,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), ?AuthorizeDiamonds),
+ high_val=any:create(orber_tc:short(), ?AuthorizeDiamonds)}}|Errors])
+ end;
+set_qos_helper([{?CycleDetection, _}|T], #state{cyclic = Cyclic} = State, Errors) ->
+ %% Currently we do not support changing the Cycle schema. If we want to,
+ %% we must copy the graph to a new instance of the correct type.
+ set_qos_helper(T, State,
+ [#'CosNotification_PropertyError'
+ {code = 'UNAVAILABLE_VALUE',
+ name = ?CycleDetection,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), Cyclic),
+ high_val=any:create(orber_tc:short(), Cyclic)}}|Errors]).
+
+%%---------------------------------------------------------------------%
+%% Function : validate_qos
+%% Arguments : WantedQoS - CosNotification::QoSProperties
+%% Returns : {ok, CosNotification::NamedPropertyRangeSeq} |
+%% {'EXCEPTION', #'CosNotification_UnsupportedQoS{}}
+%% Description: NamedPropertyRangeSeq is of out-type
+%%----------------------------------------------------------------------
+validate_qos(_OE_This, State, WantedQoS) ->
+ QoS = cosEventDomainApp:get_qos(WantedQoS),
+ {reply, {ok, validate_qos_helper(QoS, State, [], [])}, State}.
+
+validate_qos_helper([], _, Properties, []) ->
+ Properties;
+validate_qos_helper([], _, _, Errors) ->
+ corba:raise(#'CosNotification_UnsupportedQoS'{qos_err = Errors});
+validate_qos_helper([{?DiamondDetection, ?ForbidDiamonds}|T], State, Properties,
+ Errors) ->
+ case get_diamonds_helper(State, false) of
+ [] ->
+ Property =
+ #'CosNotification_NamedPropertyRange'
+ {name = ?DiamondDetection,
+ range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), ?AuthorizeDiamonds),
+ high_val=any:create(orber_tc:short(), ?ForbidDiamonds)}},
+ validate_qos_helper(T, State, [Property|Properties], Errors);
+ _ ->
+ Error =
+ #'CosNotification_PropertyError'
+ {code = 'UNAVAILABLE_VALUE',
+ name = ?DiamondDetection,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), ?AuthorizeDiamonds),
+ high_val=any:create(orber_tc:short(), ?AuthorizeDiamonds)}},
+ validate_qos_helper(T, State, Properties, [Error|Errors])
+ end;
+validate_qos_helper([{?DiamondDetection, ?AuthorizeDiamonds}|T], State, Properties,
+ Errors) ->
+ Property =
+ #'CosNotification_NamedPropertyRange'
+ {name = ?DiamondDetection,
+ range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), ?AuthorizeDiamonds),
+ high_val=any:create(orber_tc:short(), ?ForbidDiamonds)}},
+ validate_qos_helper(T, State, [Property|Properties], Errors);
+validate_qos_helper([{?CycleDetection, Cyclic}|T], #state{cyclic = Cyclic} = State,
+ Properties, Errors) ->
+ validate_qos_helper(T, State, Properties, Errors);
+validate_qos_helper([{?CycleDetection, _}|T], #state{cyclic = Cyclic} = State,
+ Properties, Errors) ->
+ Error =
+ #'CosNotification_PropertyError'
+ {code = 'UNAVAILABLE_VALUE',
+ name = ?CycleDetection,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), Cyclic),
+ high_val=any:create(orber_tc:short(), Cyclic)}},
+ validate_qos_helper(T, State, Properties, [Error|Errors]).
+
+
+%%----------------------------------------------------------------------
+%%------------------ CosNotification::AdminPropertiesAdmin -------------
+%%---------------------------------------------------------------------%
+%% Function : get_admin
+%% Arguments : -
+%% Returns : CosNotification::AdminProperties
+%% Description: No Admins currently supported
+%%----------------------------------------------------------------------
+get_admin(_OE_This, State) ->
+ {reply, [], State}.
+
+%%---------------------------------------------------------------------%
+%% Function : set_admin
+%% Arguments : NewAdmins - CosNotification::AdminProperties
+%% Returns : ok |
+%% {'EXCEPTION', #'CosNotification_UnsupportedAdmin{}}
+%% Description: No Admins currently supported
+%%----------------------------------------------------------------------
+set_admin(_OE_This, State, NewAdmins) ->
+ cosEventDomainApp:get_admin(NewAdmins),
+ {reply, ok, State}.
+
+
+%%======================================================================
+%% Internal functions
+%%======================================================================
+%%---------------------------------------------------------------------%
+%% Function : find_candidates
+%% Arguments : Digraph reference
+%% (Vertex - if we're interested in a specific vertex.
+%% Returns : {[SourceVertices], [SinkVertices], Max}
+%% SourceVertices - {Vertice, [ReachableVertices]}
+%% SinkVertices - {Vertice, [ReachingVertices]}
+%% Max - number of edges in the graph.
+%% Description: To be a part of a diamond ("transitive" relation xRy, yRz => xRz;
+%% in comparison with discrete mathematics we do not require that the
+%% entire graph is transitive) a vertex must have more than one
+%% outgoing and/or incoming. Hence, a digraph must contain at least
+%% one vertex with more than one outgoing edges and at least
+%% one with more than one incoming edges for a diamond to exist.
+%% Hence, the purpose of this function is to find vertices that
+%% look like:
+%%
+%% Vout->V1 V6->Vin
+%% \ and ^
+%% +->V2 |
+%% V8--+
+%%----------------------------------------------------------------------
+find_candidates(DG) ->
+ Edges = digraph:edges(DG),
+ {COut, CIn, Max} = find_candidates_helper(Edges, [], [], DG, 0),
+ {filter_candidates(COut), filter_candidates(CIn), Max}.
+
+
+find_candidates(DG, _Vertex) ->
+ %% We should use the fact that we know one of the vertices.
+ Edges = digraph:edges(DG),
+ {COut, CIn, Max} = find_candidates_helper(Edges, [], [], DG, 0),
+ {filter_candidates(COut), filter_candidates(CIn), Max}.
+
+find_candidates_helper([], AccOut, AccIn, _, Counter) ->
+ {lists:sort(AccOut), lists:sort(AccIn), Counter};
+find_candidates_helper([H|T], AccOut, AccIn, DG, Counter) ->
+ {H, V1, V2, _Label} = digraph:edge(DG, H),
+ find_candidates_helper(T, [{V1, V2}|AccOut], [{V2,V1}|AccIn], DG, Counter+1).
+
+filter_candidates([]) ->
+ [];
+filter_candidates([{V1, V2}|T]) ->
+ filter_candidates([{V1, V2}|T], V1, [], []).
+filter_candidates([], _V, [_Acc1], Acc2) ->
+ %% Only one in/out connection. Hence, cannot be start- or end-point
+ %% of a diamond.
+ lists:reverse(Acc2);
+filter_candidates([], V, Acc1, Acc2) ->
+ lists:reverse([{V, lists:reverse(Acc1)}|Acc2]);
+filter_candidates([{V1, V2}|T], V1, Acc1, Acc2) ->
+ filter_candidates(T, V1, [V2|Acc1], Acc2);
+filter_candidates([{V1, V2}|T], _V, [_Acc1], Acc2) ->
+ %% Only one in/out connection. Hence, cannot be start- or end-point
+ %% of a diamond.
+ filter_candidates(T, V1, [V2], Acc2);
+filter_candidates([{V1, V2}|T], V, Acc1, Acc2) ->
+ filter_candidates(T, V1, [V2], [{V, lists:reverse(Acc1)}|Acc2]).
+
+%%---------------------------------------------------------------------%
+%% Function : evaluate_candidates
+%% Arguments : -
+%% Returns : [Diamond]
+%% Description: There are several scenarios but they can be categorized as:
+%% (1) (2) (3) (4)
+%% 2 2 2-..-56
+%% / \ / \ / \
+%% 1---4 1---4 1---4 1 4
+%% \ / \ / \ /
+%% 3 3 3-..-11
+%%
+%% The purpose of this function is to find these in the cheapest
+%% way possible. For complex diamonds (may also include cycles)
+%% duplicates may be generated. For example, #2/#3 is a sub-set of #1
+%% but they are as well diamonds.
+%%----------------------------------------------------------------------
+evaluate_candidates(_DG, [], _, Acc, _Max, _) ->
+ Acc;
+evaluate_candidates(DG, [{V, OutV}|T], CIn, Acc, Max, FindAll) ->
+ case evaluate_candidates_helper(DG, V, OutV, CIn, [], FindAll) of
+ [] ->
+ evaluate_candidates(DG, T, CIn, Acc, Max, FindAll);
+ Diamonds when FindAll == true ->
+ %% May be more than one diamond.
+ evaluate_candidates(DG, T, CIn, Diamonds ++ Acc, Max, FindAll);
+ Diamond ->
+ Diamond
+ end.
+
+evaluate_candidates_helper(_, _, _, _, [Diamond], false) ->
+ Diamond;
+evaluate_candidates_helper(_, _, _, [], Diamonds, _) ->
+ Diamonds;
+evaluate_candidates_helper(DG, V1, OutV, [{V1, _InV}|T], Diamonds, FindAll) ->
+ evaluate_candidates_helper(DG, V1, OutV, T, Diamonds, FindAll);
+evaluate_candidates_helper(DG, V1, OutV, [{V2, InV}|T], Diamonds, FindAll) ->
+ case double_match(OutV, InV, [], V1, V2) of
+ [] ->
+ case is_member(InV, V1) of
+ true ->
+ %% At this point we know that we have:
+ %% x -> y
+ %% For this pair to be a part of a diamond we have two options:
+ %% (1) x - y (2) x ---- y
+ %% \ / or \ / or a additional path besides z1-zN,
+ %% z z1-zN
+ case double_match_exclude(OutV, InV, [], V1, V2) of
+ [] ->
+ %% Nope it's not #1.
+ case digraph_match(OutV, V2, V1, DG, 1) of
+ false ->
+ evaluate_candidates_helper(DG, V1, OutV, T,
+ Diamonds, FindAll);
+ Diamond ->
+ evaluate_candidates_helper(DG, V1, OutV, T,
+ [[[V1, V2]|Diamond]|Diamonds],
+ FindAll)
+ end;
+ Diamond ->
+ %% We've found a diamond looking like:
+ %% x - y xRy, yRz => xRz
+ %% \ /
+ %% z
+ evaluate_candidates_helper(DG, V1, OutV, T,
+ [[[V1, V2]|Diamond]|Diamonds],
+ FindAll)
+ end;
+ false ->
+ case digraph_match(OutV, V2, V1, DG) of
+ false ->
+ evaluate_candidates_helper(DG, V1, OutV, T,
+ Diamonds, FindAll);
+ Diamond ->
+ evaluate_candidates_helper(DG, V1, OutV, T,
+ [Diamond|Diamonds], FindAll)
+ end
+ end;
+ Diamond ->
+ %% We've found a diamond looking something like:
+ %% 2
+ %% / \
+ %% 1-5-4 V1 eq. 1, V2 eq 4.
+ %% \ /
+ %% 3
+ evaluate_candidates_helper(DG, V1, OutV, T, [Diamond|Diamonds],
+ FindAll)
+ end.
+
+is_member([], _) ->
+ false;
+is_member([H|_], H) ->
+ true;
+is_member([H|_], H2) when H > H2 ->
+ %% Since it's a sorted list no need to look any further.
+ false;
+is_member([_|T], H) ->
+ is_member(T, H).
+
+double_match([], _, [_Matched], _, _) ->
+ [];
+double_match([], _, Matched, _, _) ->
+ Matched;
+double_match(_, [], [_Matched], _, _) ->
+ [];
+double_match(_, [], Matched, _, _) ->
+ Matched;
+double_match([H|T1], [H|T2], Matched, V1, V2) ->
+ double_match(T1, T2, [[V1,H,V2] | Matched], V1, V2);
+double_match([H1|T1], [H2|T2], Matched, V1, V2) when H1 > H2 ->
+ double_match([H1|T1], T2, Matched, V1, V2);
+double_match([_H1|T1], [H2|T2], Matched, V1, V2) ->
+ double_match(T1, [H2|T2], Matched, V1, V2).
+
+double_match_exclude([], _, Matched, _, _) ->
+ Matched;
+double_match_exclude(_, [], Matched, _, _) ->
+ Matched;
+%% exclude it
+double_match_exclude([V2|T1], CIn, Matched, V1, V2) ->
+ double_match_exclude(T1, CIn, Matched, V1, V2);
+%% exclude it
+double_match_exclude(COut, [V1|T2], Matched, V1, V2) ->
+ double_match_exclude(COut, T2, Matched, V1, V2);
+%% Found match
+double_match_exclude([H|T1], [H|T2], Matched, V1, V2) ->
+ double_match_exclude(T1, T2, [[V1,H,V2] | Matched], V1, V2);
+double_match_exclude([H1|T1], [H2|T2], Matched, V1, V2) when H1 > H2 ->
+ double_match_exclude([H1|T1], T2, Matched, V1, V2);
+double_match_exclude([_H1|T1], [H2|T2], Matched, V1, V2) ->
+ double_match_exclude(T1, [H2|T2], Matched, V1, V2).
+
+
+digraph_match(OutV, V2, V1, DG) ->
+ digraph_match(OutV, V2, V1, DG, [], 0).
+
+digraph_match(OutV, V2, V1, DG, Counter) ->
+ digraph_match(OutV, V2, V1, DG, [], Counter).
+
+digraph_match([], _, _, _, _, Counter) when Counter < 2 ->
+ false;
+digraph_match([], _, _, _, Acc, _) ->
+ Acc;
+digraph_match([Vin|T], Vin, Vout, DG, Acc, Counter) ->
+ digraph_match(T, Vin, Vout, DG, Acc, Counter);
+digraph_match([H|T], Vin, Vout, DG, Acc, Counter) ->
+ case get_path(DG, H, Vin, H, Vout) of
+ false ->
+ digraph_match(T, Vin, Vout, DG, Acc, Counter);
+ Path ->
+ %% Found one path; now me must se if there are one more.
+ digraph_match(T, Vin, Vout, DG, [[Vout|lists:reverse(Path)] | Acc],
+ Counter+1)
+ end.
+
+get_path(G, V1, V2, E1, E2) ->
+ one_path(digraph:out_neighbours(G, V1), V2, [], [V1], [V1], G, E1, E2).
+
+one_path([E1|_Vs], W, Cont, Xs, Ps, G, E1, E2) ->
+ one_path([], W, Cont, Xs, Ps, G, E1, E2);
+one_path([E2|_Vs], W, Cont, Xs, Ps, G, E1, E2) ->
+ one_path([], W, Cont, Xs, Ps, G, E1, E2);
+one_path([W|_Ws], W, _Cont, _Xs, Ps, _G, _E1, _E2) ->
+ [W|Ps];
+one_path([V|Vs], W, Cont, Xs, Ps, G, E1, E2) ->
+ case lists:member(V, Xs) of
+ true -> one_path(Vs, W, Cont, Xs, Ps, G, E1, E2);
+ false -> one_path(digraph:out_neighbours(G, V), W,
+ [{Vs,Ps} | Cont], [V|Xs], [V|Ps], G, E1, E2)
+ end;
+one_path([], W, [{Vs,Ps}|Cont], Xs, _, G, E1, E2) ->
+ one_path(Vs, W, Cont, Xs, Ps, G, E1, E2);
+one_path([], _, [], _, _, _, _, _) -> false.
+
+%%---------------------------------------------------------------------%
+%% function : type_check
+%% Arguments: Obj - objectrefernce to test.
+%% Mod - Module which contains typeID/0.
+%% Returns : 'ok' or raises exception.
+%% Effect :
+%%----------------------------------------------------------------------
+type_check(Obj, Mod) ->
+ case catch corba_object:is_a(Obj,Mod:typeID()) of
+ true ->
+ ok;
+ What ->
+ orber:dbg("[~p] CosEventDomainAdmin:type_check();~n"
+ "Object of incorrect type supplied; should be: ~p~n"
+ "Failed due to: ~p", [?LINE, Mod, What], ?DEBUG_LEVEL),
+ corba:raise(#'BAD_PARAM'{minor=507, completion_status=?COMPLETED_NO})
+ end.
+
+%%---------------------------------------------------------------------%
+%% function : lookup_channel
+%% Arguments: DG - digraph reference
+%% Id - CosEventDomainAdmin::MemberID (long())
+%% Returns : CosNotifyChannelAdmin::EventChannel |
+%% {'EXCEPTION', #'CosNotifyChannelAdmin_ChannelNotFound'{}}
+%% Effect :
+%%----------------------------------------------------------------------
+lookup_channel(DG, Id) ->
+ case digraph:vertex(DG, Id) of
+ {Id, Channel} ->
+ Channel;
+ false ->
+ corba:raise(#'CosNotifyChannelAdmin_ChannelNotFound'{})
+ end.
+
+
+%%---------------------------------------------------------------------%
+%% function : lookup_connection
+%% Arguments: DG - digraph reference
+%% Id - CosEventDomainAdmin::ConnectionID (long())
+%% Returns : #connectio{} |
+%% {'EXCEPTION', #'CosEventDomainAdmin_ConnectionNotFound'{}}
+%% Effect :
+%%----------------------------------------------------------------------
+lookup_connection(DG, Id) ->
+ case digraph:edge(DG, Id) of
+ {Id, _SId, _CId, Connection} ->
+ Connection;
+ false ->
+ corba:raise(#'CosEventDomainAdmin_ConnectionNotFound'{})
+ end.
+
+%%---------------------------------------------------------------------%
+%% function : lookup_connection_data
+%% Arguments: DG - digraph reference
+%% Id - CosEventDomainAdmin::ConnectionID (long())
+%% Returns : CosEventDomainAdmin::Connection |
+%% {'EXCEPTION', #'CosEventDomainAdmin_ConnectionNotFound'{}}
+%% Effect :
+%%----------------------------------------------------------------------
+lookup_connection_data(DG, Id) ->
+ case digraph:edge(DG, Id) of
+ {Id, _SId, _CId, #connection{data = Connection}} ->
+ Connection;
+ false ->
+ corba:raise(#'CosEventDomainAdmin_ConnectionNotFound'{})
+ end.
+
+%%---------------------------------------------------------------------%
+%% function : close_connections
+%% Arguments: DG -digraph reference
+%% [CosEventDomainAdmin::ConnectionID] - [long()]
+%% Returns : ok
+%% Effect :
+%%----------------------------------------------------------------------
+close_connections(_DG, []) ->
+ ok;
+close_connections(DG, [H|T]) ->
+ #connection{supplier=S, consumer=C, data=Connection} =
+ lookup_connection(DG, H),
+ close_connection(Connection, S, C),
+ digraph:del_edge(DG, H),
+ close_connections(DG, T).
+
+%%---------------------------------------------------------------------%
+%% function : close_connection
+%% Arguments: CosEventDomainAdmin::Connection
+%% S - SupplierProxy
+%% C - ConsumerProxy
+%% Returns : ok
+%% Effect :
+%%----------------------------------------------------------------------
+close_connection(#'CosEventDomainAdmin_Connection'{ctype=Type,
+ notification_style = Style},
+ S, C) ->
+ case {Type, Style} of
+ {'ANY_EVENT', 'Push'} ->
+ catch 'CosNotifyChannelAdmin_ProxyPushSupplier':disconnect_push_supplier(S),
+ catch 'CosNotifyChannelAdmin_ProxyPushConsumer':disconnect_push_consumer(C);
+ {'ANY_EVENT', 'Pull'} ->
+ catch 'CosNotifyChannelAdmin_ProxyPullSupplier':disconnect_pull_supplier(S),
+ catch 'CosNotifyChannelAdmin_ProxyPullConsumer':disconnect_pull_consumer(C);
+ {'STRUCTURED_EVENT', 'Push'} ->
+ catch 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':disconnect_structured_push_supplier(S),
+ catch 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':disconnect_structured_push_consumer(C);
+ {'STRUCTURED_EVENT', 'Pull'} ->
+ catch 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':disconnect_structured_pull_supplier(S),
+ catch 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':disconnect_structured_pull_consumer(C);
+ {'SEQUENCE_EVENT', 'Push'} ->
+ catch 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':disconnect_sequence_push_supplier(S),
+ catch 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':disconnect_sequence_push_consumer(C);
+ {'SEQUENCE_EVENT', 'Pull'}->
+ catch 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':disconnect_sequence_pull_supplier(S),
+ catch 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':disconnect_sequence_pull_consumer(C)
+ end,
+ ok.
+
+%%---------------------------------------------------------------------%
+%% function : setup_connection
+%% Arguments: CosEventDomainAdmin::Connection
+%% S - SupplierProxy
+%% C - ConsumerProxy
+%% Returns : {ok, SupplierProxy, ConsumerProxy};
+%% Effect :
+%%----------------------------------------------------------------------
+setup_connection(#'CosEventDomainAdmin_Connection'{ctype=Type,
+ notification_style = Style},
+ S, C) ->
+ Admin =
+ 'CosNotifyChannelAdmin_EventChannel':'_get_default_consumer_admin'(S),
+ case Style of
+ 'Push' ->
+ {Proxy, _Id} =
+ 'CosNotifyChannelAdmin_ConsumerAdmin':
+ obtain_notification_push_supplier(Admin, Type),
+ CProxy = connect_a_push_supplier(C, Proxy, Type),
+ case Type of
+ 'ANY_EVENT' ->
+ 'CosNotifyChannelAdmin_ProxyPushSupplier':
+ connect_any_push_consumer(Proxy, CProxy);
+ 'STRUCTURED_EVENT' ->
+ 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':
+ connect_structured_push_consumer(Proxy, CProxy);
+ 'SEQUENCE_EVENT' ->
+ 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':
+ connect_sequence_push_consumer(Proxy, CProxy)
+ end,
+ {ok, Proxy, CProxy};
+ 'Pull' ->
+ {Proxy, _Id} =
+ 'CosNotifyChannelAdmin_ConsumerAdmin':
+ obtain_notification_pull_supplier(Admin, Type),
+ CProxy = connect_a_pull_supplier(C, Proxy, Type),
+ case Type of
+ 'ANY_EVENT' ->
+ 'CosNotifyChannelAdmin_ProxyPullSupplier':
+ connect_any_pull_consumer(Proxy, CProxy);
+ 'STRUCTURED_EVENT' ->
+ 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':
+ connect_structured_pull_consumer(Proxy, CProxy);
+ 'SEQUENCE_EVENT' ->
+ 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':
+ connect_sequence_pull_consumer(Proxy, CProxy)
+ end,
+ {ok, Proxy, CProxy}
+ end.
+
+%%---------------------------------------------------------------------%
+%% function : connect_a_pull_consumer
+%% Arguments: Channel - CosNotifyChannelAdmin::EventChannel | undefined
+%% PC - a PullConsumer
+%% Type - 'ANY_EVENT' | 'STRUCTURED_EVENT' | 'SEQUENCE_EVENT'
+%% Returns :
+%% Effect :
+%%----------------------------------------------------------------------
+connect_a_pull_consumer(undefined, _, _) ->
+ corba:raise(#'CosNotifyChannelAdmin_ChannelNotFound'{});
+connect_a_pull_consumer(Channel, PC, Type) ->
+ Admin =
+ 'CosNotifyChannelAdmin_EventChannel':'_get_default_consumer_admin'(Channel),
+ {Proxy, _Id} =
+ 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_pull_supplier(Admin,
+ Type),
+ case Type of
+ 'ANY_EVENT' ->
+ 'CosNotifyChannelAdmin_ProxyPullSupplier':connect_any_pull_consumer(Proxy, PC);
+ 'STRUCTURED_EVENT' ->
+ 'CosNotifyChannelAdmin_StructuredProxyPullSupplier':connect_structured_pull_consumer(Proxy, PC);
+ 'SEQUENCE_EVENT' ->
+ 'CosNotifyChannelAdmin_SequenceProxyPullSupplier':connect_sequence_pull_consumer(Proxy, PC)
+ end,
+ Proxy.
+
+%%---------------------------------------------------------------------%
+%% function : connect_a_push_consumer
+%% Arguments: Channel - CosNotifyChannelAdmin::EventChannel | undefined
+%% PC - a PushConsumer
+%% Type - 'ANY_EVENT' | 'STRUCTURED_EVENT' | 'SEQUENCE_EVENT'
+%% Returns :
+%% Effect :
+%%----------------------------------------------------------------------
+connect_a_push_consumer(undefined, _, _) ->
+ corba:raise(#'CosNotifyChannelAdmin_ChannelNotFound'{});
+connect_a_push_consumer(Channel, PC, Type) ->
+ Admin =
+ 'CosNotifyChannelAdmin_EventChannel':'_get_default_consumer_admin'(Channel),
+ {Proxy, _Id} =
+ 'CosNotifyChannelAdmin_ConsumerAdmin':obtain_notification_push_supplier(Admin,
+ Type),
+ case Type of
+ 'ANY_EVENT' ->
+ 'CosNotifyChannelAdmin_ProxyPushSupplier':connect_any_push_consumer(Proxy, PC);
+ 'STRUCTURED_EVENT' ->
+ 'CosNotifyChannelAdmin_StructuredProxyPushSupplier':connect_structured_push_consumer(Proxy, PC);
+ 'SEQUENCE_EVENT' ->
+ 'CosNotifyChannelAdmin_SequenceProxyPushSupplier':connect_sequence_push_consumer(Proxy, PC)
+ end,
+ Proxy.
+
+%%---------------------------------------------------------------------%
+%% function : connect_a_pull_supplier
+%% Arguments: Channel - CosNotifyChannelAdmin::EventChannel | undefined
+%% PC - a PullSupplier
+%% Type - 'ANY_EVENT' | 'STRUCTURED_EVENT' | 'SEQUENCE_EVENT'
+%% Returns :
+%% Effect :
+%%----------------------------------------------------------------------
+connect_a_pull_supplier(undefined, _, _) ->
+ corba:raise(#'CosNotifyChannelAdmin_ChannelNotFound'{});
+connect_a_pull_supplier(Channel, PS, Type) ->
+ Admin =
+ 'CosNotifyChannelAdmin_EventChannel':'_get_default_supplier_admin'(Channel),
+ {Proxy, _Id} =
+ 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_pull_consumer(Admin,
+ Type),
+ case Type of
+ 'ANY_EVENT' ->
+ 'CosNotifyChannelAdmin_ProxyPullConsumer':connect_any_pull_supplier(Proxy, PS);
+ 'STRUCTURED_EVENT' ->
+ 'CosNotifyChannelAdmin_StructuredProxyPullConsumer':connect_structured_pull_supplier(Proxy, PS);
+ 'SEQUENCE_EVENT' ->
+ 'CosNotifyChannelAdmin_SequenceProxyPullConsumer':connect_sequence_pull_supplier(Proxy, PS)
+ end,
+ Proxy.
+
+%%---------------------------------------------------------------------%
+%% function : connect_a_push_supplier
+%% Arguments: Channel - CosNotifyChannelAdmin::EventChannel | undefined
+%% PC - a PushSupplier
+%% Type - 'ANY_EVENT' | 'STRUCTURED_EVENT' | 'SEQUENCE_EVENT'
+%% Returns :
+%% Effect :
+%%----------------------------------------------------------------------
+connect_a_push_supplier(undefined, _, _) ->
+ corba:raise(#'CosNotifyChannelAdmin_ChannelNotFound'{});
+connect_a_push_supplier(Channel, PS, Type) ->
+ Admin =
+ 'CosNotifyChannelAdmin_EventChannel':'_get_default_supplier_admin'(Channel),
+ {Proxy, _Id} =
+ 'CosNotifyChannelAdmin_SupplierAdmin':obtain_notification_push_consumer(Admin,
+ Type),
+ case Type of
+ 'ANY_EVENT' ->
+ 'CosNotifyChannelAdmin_ProxyPushConsumer':connect_any_push_supplier(Proxy, PS);
+ 'STRUCTURED_EVENT' ->
+ 'CosNotifyChannelAdmin_StructuredProxyPushConsumer':connect_structured_push_supplier(Proxy, PS);
+ 'SEQUENCE_EVENT' ->
+ 'CosNotifyChannelAdmin_SequenceProxyPushConsumer':connect_sequence_push_supplier(Proxy, PS)
+ end,
+ Proxy.
+
+
+%%======================================================================
+%% END OF MODULE
+%%======================================================================
+
diff --git a/lib/cosEventDomain/src/Makefile b/lib/cosEventDomain/src/Makefile
new file mode 100644
index 0000000000..56a67cd225
--- /dev/null
+++ b/lib/cosEventDomain/src/Makefile
@@ -0,0 +1,179 @@
+#
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2001-2009. All Rights Reserved.
+#
+# The contents of this file are subject to the Erlang Public License,
+# Version 1.1, (the "License"); you may not use this file except in
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+#
+#
+include $(ERL_TOP)/make/target.mk
+ifeq ($(TYPE),debug)
+ERL_COMPILE_FLAGS += -Ddebug -W
+endif
+EBIN=../ebin
+include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+include ../vsn.mk
+VSN=$(COSEVENTDOMAIN_VSN)
+
+# ----------------------------------------------------
+# Release directory specification
+# ----------------------------------------------------
+RELSYSDIR = $(RELEASE_PATH)/lib/cosEventDomain-$(VSN)
+# ----------------------------------------------------
+# Target Specs
+# ----------------------------------------------------
+
+MODULES = \
+ CosEventDomainAdmin_EventDomainFactory_impl \
+ CosEventDomainAdmin_EventDomain_impl \
+ cosEventDomainApp
+
+ERL_FILES = $(MODULES:%=%.erl)
+HRL_FILES = cosEventDomainApp.hrl
+
+EXTERNAL_INC_PATH = ../include
+
+GEN_ERL_FILES = \
+ oe_CosEventDomainAdmin.erl \
+ CosEventDomainAdmin.erl \
+ CosEventDomainAdmin_DiamondSeq.erl \
+ CosEventDomainAdmin_AlreadyExists.erl \
+ CosEventDomainAdmin_DomainIDSeq.erl \
+ CosEventDomainAdmin_Connection.erl \
+ CosEventDomainAdmin_ConnectionIDSeq.erl \
+ CosEventDomainAdmin_ConnectionNotFound.erl \
+ CosEventDomainAdmin_CycleCreationForbidden.erl \
+ CosEventDomainAdmin_CycleSeq.erl \
+ CosEventDomainAdmin_DiamondCreationForbidden.erl \
+ CosEventDomainAdmin_DomainNotFound.erl \
+ CosEventDomainAdmin_EventDomain.erl \
+ CosEventDomainAdmin_EventDomainFactory.erl \
+ CosEventDomainAdmin_MemberIDSeq.erl \
+ CosEventDomainAdmin_RouteSeq.erl
+
+
+
+GEN_HRL_FILES = \
+ oe_CosEventDomainAdmin.hrl \
+ CosEventDomainAdmin.hrl \
+ CosEventDomainAdmin_EventDomainFactory.hrl \
+ CosEventDomainAdmin_EventDomain.hrl
+
+EXTERNAL_GEN_HRL_FILES = \
+ $(GEN_HRL_FILES:%=$(EXTERNAL_INC_PATH)/%)
+
+
+TARGET_FILES = \
+ $(GEN_ERL_FILES:%.erl=$(EBIN)/%.$(EMULATOR)) \
+ $(MODULES:%=$(EBIN)/%.$(EMULATOR))
+
+GEN_FILES = $(GEN_HRL_FILES) $(GEN_ERL_FILES)
+
+IDL_FILES = \
+ CosEventDomainAdmin.idl
+
+APPUP_FILE = cosEventDomain.appup
+APPUP_SRC = $(APPUP_FILE).src
+APPUP_TARGET = $(EBIN)/$(APPUP_FILE)
+
+APP_FILE = cosEventDomain.app
+APP_SRC = $(APP_FILE).src
+APP_TARGET = $(EBIN)/$(APP_FILE)
+
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+ERL_IDL_FLAGS += \
+ -pa $(ERL_TOP)/lib/cosEventDomain/ebin \
+ -pa $(ERL_TOP)/lib/cosEventDomain/include \
+ -pa $(ERL_TOP)/lib/cosNotification/include \
+ -pa $(ERL_TOP)/lib/cosNotification/ebin \
+ -pa $(ERL_TOP)/lib/ic/ebin \
+ -I$(ERL_TOP)/lib/cosNotification/include \
+ -I$(ERL_TOP)/lib/cosNotification/ebin \
+ -I$(ERL_TOP)/lib/cosNotification/src \
+ -I$(ERL_TOP)/lib/cosEvent/src \
+ -I$(ERL_TOP)/lib/cosEventDomain/include
+# The -pa option is just used temporary until erlc can handle
+# includes from other directories than ../include .
+ERL_COMPILE_FLAGS += \
+ $(ERL_IDL_FLAGS) \
+ -pa $(ERL_TOP)/lib/cosEventDomain/include \
+ -pa $(ERL_TOP)/lib/cosNotification/ebin \
+ -pa $(ERL_TOP)/lib/cosNotification/include \
+ -pa $(ERL_TOP)/lib/cosNotification/src \
+ -I$(ERL_TOP)/lib/cosEventDomain/include \
+ -I$(ERL_TOP)/lib/cosNotification/ebin \
+ -I$(ERL_TOP)/lib/cosNotification/include \
+ -I$(ERL_TOP)/lib/cosNotification/src \
+ -I$(ERL_TOP)/lib/cosEvent/src \
+ -I$(ERL_TOP)/lib/cosEvent/include \
+ +'{parse_transform,sys_pre_attributes}' \
+ +'{attribute,insert,app_vsn,"cosEventDomain_$(COSEVENTDOMAIN_VSN)"}'
+
+YRL_FLAGS =
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+opt: $(TARGET_FILES) $(APP_TARGET) $(APPUP_TARGET)
+
+debug:
+ @${MAKE} TYPE=debug opt
+
+clean:
+ rm -f $(TARGET_FILES) $(GEN_FILES) $(APP_TARGET) $(APPUP_TARGET)
+ rm -f errs core *~
+
+$(APP_TARGET): $(APP_SRC)
+ sed -e 's;%VSN%;$(VSN);' $(APP_SRC) > $(APP_TARGET)
+$(APPUP_TARGET): $(APPUP_SRC)
+ sed -e 's;%VSN%;$(VSN);' $(APPUP_SRC) > $(APPUP_TARGET)
+
+docs:
+
+# ----------------------------------------------------
+# Special Build Targets
+# ----------------------------------------------------
+$(GEN_ERL_FILES) $(EXTERNAL_GEN_HRL_FILES): CosEventDomainAdmin.idl
+ erlc $(ERL_IDL_FLAGS) +'{cfgfile,"CosEventDomainAdmin.cfg"}' CosEventDomainAdmin.idl
+ mv $(GEN_HRL_FILES) $(EXTERNAL_INC_PATH)
+
+# ----------------------------------------------------
+# Release Target
+# ----------------------------------------------------
+include $(ERL_TOP)/make/otp_release_targets.mk
+
+
+release_spec: opt
+ $(INSTALL_DIR) $(RELSYSDIR)
+ $(INSTALL_DATA) ../info $(RELSYSDIR)
+ $(INSTALL_DIR) $(RELSYSDIR)/ebin
+ $(INSTALL_DATA) $(TARGET_FILES) $(APP_TARGET) $(APPUP_TARGET) $(RELSYSDIR)/ebin
+ $(INSTALL_DIR) $(RELSYSDIR)/src
+ $(INSTALL_DATA) $(ERL_FILES) $(HRL_FILES) $(GEN_ERL_FILES) $(IDL_FILES) $(RELSYSDIR)/src
+ $(INSTALL_DIR) $(RELSYSDIR)/include
+ $(INSTALL_DATA) $(EXTERNAL_GEN_HRL_FILES) $(RELSYSDIR)/include
+
+
+release_docs_spec:
+
+
+
+
+
diff --git a/lib/cosEventDomain/src/cosEventDomain.app.src b/lib/cosEventDomain/src/cosEventDomain.app.src
new file mode 100644
index 0000000000..e4307e1f99
--- /dev/null
+++ b/lib/cosEventDomain/src/cosEventDomain.app.src
@@ -0,0 +1,31 @@
+{application, cosEventDomain,
+ [{description, "The Erlang CosEventDomain application"},
+ {vsn, "%VSN%"},
+ {modules,
+ [
+ 'CosEventDomainAdmin_EventDomainFactory_impl',
+ 'CosEventDomainAdmin_EventDomain_impl',
+ 'cosEventDomainApp',
+ 'oe_CosEventDomainAdmin',
+ 'CosEventDomainAdmin',
+ 'CosEventDomainAdmin_DiamondSeq',
+ 'CosEventDomainAdmin_AlreadyExists',
+ 'CosEventDomainAdmin_DomainIDSeq',
+ 'CosEventDomainAdmin_Connection',
+ 'CosEventDomainAdmin_ConnectionIDSeq',
+ 'CosEventDomainAdmin_ConnectionNotFound',
+ 'CosEventDomainAdmin_CycleCreationForbidden',
+ 'CosEventDomainAdmin_CycleSeq',
+ 'CosEventDomainAdmin_DiamondCreationForbidden',
+ 'CosEventDomainAdmin_DomainNotFound',
+ 'CosEventDomainAdmin_EventDomain',
+ 'CosEventDomainAdmin_EventDomainFactory',
+ 'CosEventDomainAdmin_MemberIDSeq',
+ 'CosEventDomainAdmin_RouteSeq'
+ ]
+ },
+ {registered, []},
+ {applications, [orber, stdlib, kernel]},
+ {env, []},
+ {mod, {cosEventDomainApp, []}}
+]}.
diff --git a/lib/cosEventDomain/src/cosEventDomain.appup.src b/lib/cosEventDomain/src/cosEventDomain.appup.src
new file mode 100644
index 0000000000..d69b2ef20c
--- /dev/null
+++ b/lib/cosEventDomain/src/cosEventDomain.appup.src
@@ -0,0 +1,6 @@
+{"%VSN%",
+ [
+ ],
+ [
+ ]
+}
diff --git a/lib/cosEventDomain/src/cosEventDomainApp.erl b/lib/cosEventDomain/src/cosEventDomainApp.erl
new file mode 100644
index 0000000000..d57f51443c
--- /dev/null
+++ b/lib/cosEventDomain/src/cosEventDomainApp.erl
@@ -0,0 +1,363 @@
+%%--------------------------------------------------------------------
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+%%--------------------------------------------------------------------
+%% File : cosEventDomainApp.erl
+%% Purpose :
+%%--------------------------------------------------------------------
+
+-module(cosEventDomainApp).
+
+%%--------------- INCLUDES -----------------------------------
+-include_lib("orber/include/corba.hrl").
+-include_lib("orber/include/ifr_types.hrl").
+-include_lib("cosNotification/include/CosNotification.hrl").
+%% Application files
+-include("cosEventDomainApp.hrl").
+-include("CosEventDomainAdmin.hrl").
+
+%%--------------- EXPORTS ------------------------------------
+%% External MISC
+-export([get_option/3,
+ create_name/2,
+ create_name/1,
+ create_id/0,
+ create_id/1,
+ is_debug_compiled/0,
+ install/0,
+ uninstall/0,
+ start_factory/0,
+ start_factory/1,
+ start_factory_link/0,
+ start_factory_link/1,
+ stop_factory/1,
+ start/0,
+ stop/0,
+ create_link/3,
+ get_qos/1,
+ get_admin/1]).
+
+%% Application callbacks
+-export([start/2, init/1, stop/1]).
+
+%%--------------- DEFINES ------------------------------------
+
+-define(SUPERVISOR_NAME, oe_cosEventDomainSup).
+-define(SUP_FLAG, {simple_one_for_one,50,10}).
+
+-define(SUP_SPEC(Name, Args),
+ ['CosEventDomainAdmin_EventDomain',Args,
+ [{sup_child, true}, {regname, {global, Name}}]]).
+-define(SUP_CHILD,
+ {"oe_EventDomainChild",
+ {cosEventDomainApp,create_link, []},
+ transient,100000,worker,
+ ['CosEventDomainAdmin_EventDomain']}).
+
+
+-define(DEFAULT_OPTIONS, []).
+
+%%--------------- DEFINITIONS OF CONSTANTS -------------------
+%%--------------- EXTERNAL MISC FUNCTIONS --------------------
+%%-----------------------------------------------------------%
+%% function : install
+%% Arguments:
+%% Returns :
+%% Exception:
+%% Effect :
+%%------------------------------------------------------------
+install() ->
+ oe_CosEventDomainAdmin:oe_register().
+
+%%-----------------------------------------------------------%
+%% function : uninstall
+%% Arguments:
+%% Returns :
+%% Exception:
+%% Effect :
+%%------------------------------------------------------------
+uninstall() ->
+ oe_CosEventDomainAdmin:oe_unregister().
+
+%%-----------------------------------------------------------%
+%% function : start/stop
+%% Arguments:
+%% Returns :
+%% Effect : Starts or stops the cosTime application.
+%%------------------------------------------------------------
+
+start() ->
+ application:start(cosEventDomain).
+stop() ->
+ application:stop(cosEventDomain).
+
+%%-----------------------------------------------------------%
+%% function : start
+%% Arguments: Type - see module application
+%% Arg - see module application
+%% Returns :
+%% Effect : Module callback for application
+%%------------------------------------------------------------
+
+start(_, _) ->
+ supervisor:start_link({local, ?SUPERVISOR_NAME}, cosEventDomainApp, app_init).
+
+
+%%-----------------------------------------------------------%
+%% function : stop
+%% Arguments: Arg - see module application
+%% Returns :
+%% Effect : Module callback for application
+%%------------------------------------------------------------
+
+stop(_) ->
+ ok.
+
+%%-----------------------------------------------------------%
+%% function : start_channel
+%% Arguments: -
+%% Returns :
+%% Effect :
+%%------------------------------------------------------------
+start_factory() ->
+ start_factory(?DEFAULT_OPTIONS).
+
+start_factory(Options) when is_list(Options) ->
+ 'CosEventDomainAdmin_EventDomainFactory':oe_create(Options);
+start_factory(Options) ->
+ orber:dbg("[~p] cosEventDomainApp:start_factory(~p);~n"
+ "Options not correct.",
+ [?LINE, Options], ?DEBUG_LEVEL),
+ corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).
+
+%%-----------------------------------------------------------%
+%% function : start_channel
+%% Arguments: -
+%% Returns :
+%% Effect :
+%%------------------------------------------------------------
+start_factory_link() ->
+ start_factory_link(?DEFAULT_OPTIONS).
+
+start_factory_link(Options) when is_list(Options) ->
+ 'CosEventDomainAdmin_EventDomainFactory':oe_create_link(Options);
+start_factory_link(Options) ->
+ orber:dbg("[~p] cosEventDomainApp:start_factory_link(~p);~n"
+ "Options not correct.",
+ [?LINE, Options], ?DEBUG_LEVEL),
+ corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).
+
+%%-----------------------------------------------------------%
+%% function : stop_factory
+%% Arguments: ChannelObj
+%% Returns :
+%% Effect :
+%%------------------------------------------------------------
+stop_factory(ChannelObj) ->
+ corba:dispose(ChannelObj).
+
+%%-----------------------------------------------------------%
+%% function : init
+%% Arguments:
+%% Returns :
+%% Effect :
+%%------------------------------------------------------------
+
+%% Starting using create_factory/X
+init(own_init) ->
+ {ok,{?SUP_FLAG, [?SUP_CHILD]}};
+%% When starting as an application.
+init(app_init) ->
+ {ok,{?SUP_FLAG, [?SUP_CHILD]}}.
+
+
+%%------------------------------------------------------------
+%% function : create_link
+%% Arguments: Module - which Module to call
+%% Env/ArgList - ordinary oe_create arguments.
+%% Returns :
+%% Exception:
+%% Effect : Necessary since we want the supervisor to be a
+%% 'simple_one_for_one'. Otherwise, using for example,
+%% 'one_for_one', we have to call supervisor:delete_child
+%% to remove the childs startspecification from the
+%% supervisors internal state.
+%%------------------------------------------------------------
+create_link(Module, Env, ArgList) ->
+ Module:oe_create_link(Env, ArgList).
+
+%%-----------------------------------------------------------%
+%% function : get_option
+%% Arguments:
+%% Returns :
+%% Exception:
+%% Effect :
+%%------------------------------------------------------------
+get_option(Key, OptionList, DefaultList) ->
+ case lists:keysearch(Key, 1, OptionList) of
+ {value,{Key,Value}} ->
+ Value;
+ _ ->
+ case lists:keysearch(Key, 1, DefaultList) of
+ {value,{Key,Value}} ->
+ Value;
+ _->
+ {error, "Invalid option"}
+ end
+ end.
+%%-----------------------------------------------------------%
+%% function : create_name/2
+%% Arguments:
+%% Returns :
+%% Exception:
+%% Effect :
+%%------------------------------------------------------------
+create_name(Name,Type) ->
+ {MSec, Sec, USec} = erlang:now(),
+ lists:concat(['oe_',node(),'_',Type,'_',Name,'_',MSec, '_', Sec, '_', USec]).
+
+%%-----------------------------------------------------------%
+%% function : create_name/1
+%% Arguments:
+%% Returns :
+%% Exception:
+%% Effect :
+%%------------------------------------------------------------
+create_name(Type) ->
+ {MSec, Sec, USec} = erlang:now(),
+ lists:concat(['oe_',node(),'_',Type,'_',MSec, '_', Sec, '_', USec]).
+
+%%------------------------------------------------------------
+%% function : create_id/0
+%% Arguments: -
+%% Returns : CosEventDomainAdmin::DomainID (long)
+%% Exception:
+%% Purpose :
+%%------------------------------------------------------------
+create_id(2147483647) ->
+ -2147483648;
+create_id(OldID) ->
+ OldID+1.
+
+
+create_id() ->
+ {_A,_B,C}=now(),
+ C.
+%%------------------------------------------------------------
+%% function : get_qos
+%% Arguments:
+%% Returns :
+%% Exception:
+%% Effect :
+%%------------------------------------------------------------
+get_qos([]) ->
+ [];
+get_qos(Properties) ->
+ get_qos(Properties, [], []).
+
+get_qos([], Supported, []) ->
+ Supported;
+get_qos([], _, Unsupported) ->
+ corba:raise(#'CosNotification_UnsupportedQoS'{qos_err = Unsupported});
+get_qos([#'CosNotification_Property'{name = ?CycleDetection,
+ value= #any{value = ?AuthorizeCycles}}|T],
+ Supported, Unsupported) ->
+ get_qos(T, [{?CycleDetection, ?AuthorizeCycles}|Supported], Unsupported);
+get_qos([#'CosNotification_Property'{name = ?CycleDetection,
+ value= #any{value = ?ForbidCycles}}|T],
+ Supported, Unsupported) ->
+ get_qos(T, [{?CycleDetection, ?ForbidCycles}|Supported], Unsupported);
+get_qos([#'CosNotification_Property'{name = ?CycleDetection}|T],
+ Supported, Unsupported) ->
+ %% Illegal value supplied.
+ get_qos(T, Supported,
+ [#'CosNotification_PropertyError'
+ {code = 'UNSUPPORTED_VALUE',
+ name = ?CycleDetection,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), ?AuthorizeCycles),
+ high_val=any:create(orber_tc:short(), ?ForbidCycles)}}|Unsupported]);
+get_qos([#'CosNotification_Property'{name = ?DiamondDetection,
+ value= #any{value = ?AuthorizeDiamonds}}|T],
+ Supported, Unsupported) ->
+ get_qos(T, [{?DiamondDetection, ?AuthorizeDiamonds}|Supported], Unsupported);
+get_qos([#'CosNotification_Property'{name = ?DiamondDetection,
+ value= #any{value = ?ForbidDiamonds}}|T],
+ Supported, Unsupported) ->
+ get_qos(T, [{?DiamondDetection, ?ForbidDiamonds}|Supported], Unsupported);
+get_qos([#'CosNotification_Property'{name = ?DiamondDetection}|T],
+ Supported, Unsupported) ->
+ %% Illegal value supplied.
+ get_qos(T, Supported,
+ [#'CosNotification_PropertyError'
+ {code = 'UNSUPPORTED_VALUE',
+ name = ?DiamondDetection,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:short(), ?AuthorizeDiamonds),
+ high_val=any:create(orber_tc:short(), ?ForbidDiamonds)
+ }} | Unsupported]);
+get_qos([#'CosNotification_Property'{name = Name}|T], Supported, Unsupported) ->
+ %% Unknown QoS supplied.
+ get_qos(T, Supported,
+ [#'CosNotification_PropertyError'
+ {code = 'BAD_PROPERTY',
+ name = Name,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:null(), null),
+ high_val=any:create(orber_tc:null(), null)}} | Unsupported]).
+
+%%------------------------------------------------------------
+%% function : get_admin
+%% Arguments:
+%% Returns : {"EXCEPTION', #'CosNotification_PropertyError'{}}
+%% Exception:
+%% Effect : No Admin supported.
+%%------------------------------------------------------------
+get_admin([]) ->
+ [];
+get_admin(Properties) ->
+ get_admin(Properties, []).
+
+get_admin([], Unsupported) ->
+ corba:raise(#'CosNotification_UnsupportedAdmin'{admin_err = Unsupported});
+get_admin([#'CosNotification_Property'{name = Name}|T], Unsupported) ->
+ %% Unknown QoS supplied.
+ get_admin(T, [#'CosNotification_PropertyError'
+ {code = 'BAD_PROPERTY',
+ name = Name,
+ available_range = #'CosNotification_PropertyRange'
+ {low_val=any:create(orber_tc:null(), null),
+ high_val=any:create(orber_tc:null(), null)}} | Unsupported]).
+
+
+%%------------------------------------------------------------
+%% function : is_debug_compiled
+%% Arguments:
+%% Returns :
+%% Exception:
+%% Effect :
+%%------------------------------------------------------------
+-ifdef(debug).
+ is_debug_compiled() -> true.
+-else.
+ is_debug_compiled() -> false.
+-endif.
+
+%%--------------- END OF MODULE ------------------------------
diff --git a/lib/cosEventDomain/src/cosEventDomainApp.hrl b/lib/cosEventDomain/src/cosEventDomainApp.hrl
new file mode 100644
index 0000000000..340bbc52d2
--- /dev/null
+++ b/lib/cosEventDomain/src/cosEventDomainApp.hrl
@@ -0,0 +1,69 @@
+%%----------------------------------------------------------------------
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+%%
+%%----------------------------------------------------------------------
+%% File : cosEventDomainApp.hrl
+%% Purpose :
+%%----------------------------------------------------------------------
+
+
+%%--------------- INCLUDES -----------------------------------
+%% External
+
+%% Local
+
+-define(write_ErrorMsg(Txt, Arg),
+error_logger:error_msg("============== CosEventDomain =============~n"
+ Txt
+ "===========================================~n",
+ Arg)).
+
+-define(DEBUG_LEVEL, 3).
+
+-ifdef(debug).
+-define(DBG(F,A),
+ io:format("[LINE: ~p MODULE: ~p] "++F,[?LINE, ?MODULE]++A)).
+-else.
+-define(DBG(F,A), ok).
+-endif.
+
+%%%%%% WARNING! These definitions are defined in the CosEventDomainAdmin.idl
+%%%%%% file. If the specification is changed so must the definitions!!
+%%%%%% We use this approach to be able to use them as guards.
+
+%%%% Constant: 'CycleDetection'
+-define(CycleDetection, "CycleDetection").
+
+%%%% Constant: 'AuthorizeCycles'
+-define(AuthorizeCycles, 0).
+
+%%%% Constant: 'ForbidCycles'
+-define(ForbidCycles, 1).
+
+%%%% Constant: 'DiamondDetection'
+-define(DiamondDetection, "DiamondDetection").
+
+%%%% Constant: 'AuthorizeDiamonds'
+-define(AuthorizeDiamonds, 0).
+
+%%%% Constant: 'ForbidDiamonds'
+-define(ForbidDiamonds, 1).
+
+%%--------------- END OF MODULE ------------------------------