pullersupplier_impl.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 914 行 · 第 1/3 页

ERL
914
字号
%%-----------------------------------------------------------%%----------------------------------------------------------%%% Attribute: '_get_MyType'%% Type     : readonly%% Returns  : %%-----------------------------------------------------------'_get_MyType'(_OE_THIS, _OE_FROM, State) ->    {reply, ?get_MyType(State), State}.%%----------------------------------------------------------%%% Attribute: '_get_MyAdmin'%% Type     : readonly%% Returns  : %%-----------------------------------------------------------'_get_MyAdmin'(_OE_THIS, _OE_FROM, State) ->    {reply, ?get_MyAdmin(State), State}.%%----------------------------------------------------------%%% Attribute: '_*et_priority_filter'%% Type     : read/write%% Returns  : %%-----------------------------------------------------------'_get_priority_filter'(_OE_THIS, _OE_FROM, State) ->    {reply, ?get_PrioFil(State), State}.'_set_priority_filter'(_OE_THIS, _OE_FROM, State, PrioF) ->    {reply, ok, ?set_PrioFil(State, PrioF)}.%%----------------------------------------------------------%%% Attribute: '_*et_lifetime_filter'%% Type     : read/write%% Returns  : %%-----------------------------------------------------------'_get_lifetime_filter'(_OE_THIS, _OE_FROM, State) ->    {reply, ?get_LifeTFil(State), State}.'_set_lifetime_filter'(_OE_THIS, _OE_FROM, State, LifeTF) ->    {reply, ok, ?set_LifeTFil(State, LifeTF)}.%%-----------------------------------------------------------%%------- Exported external functions -----------------------%%-----------------------------------------------------------%%----- CosEventChannelAdmin::ProxyPullSupplier -------------%%----------------------------------------------------------%%% function : connect_pull_consumer%% Arguments: Client - CosEventComm::PullConsumer%% Returns  :  ok | {'EXCEPTION', #'AlreadyConnected'{}} |%%            {'EXCEPTION', #'TypeError'{}} |%%            {'EXCEPTION', #'BAD_OPERATION'{}}%%            Both exceptions from CosEventChannelAdmin!!!%%-----------------------------------------------------------connect_pull_consumer(OE_THIS, OE_FROM, State, Client) ->    connect_any_pull_consumer(OE_THIS, OE_FROM, State, Client).%%----- CosNotifyChannelAdmin::ProxyPullSupplier ------------%%----------------------------------------------------------%%% function : connect_any_pull_consumer%% Arguments: Client - CosEventComm::PullConsumer%% Returns  :  ok | {'EXCEPTION', #'AlreadyConnected'{}} |%%            {'EXCEPTION', #'TypeError'{}} |%%            {'EXCEPTION', #'BAD_OPERATION'{}}%%            Both exceptions from CosEventChannelAdmin!!!%%-----------------------------------------------------------connect_any_pull_consumer(_OE_THIS, _OE_FROM, State, Client) when ?is_ANY(State) ->    ?not_TypeCheck(Client, 'CosEventComm_PullConsumer'),    if	?is_Connected(State) ->	    corba:raise(#'CosEventChannelAdmin_AlreadyConnected'{});	true ->	    {reply, ok, ?set_Client(State, Client)}    end;connect_any_pull_consumer(_, _, _, _) ->      corba:raise(#'BAD_OPERATION'{completion_status=?COMPLETED_NO}).  %%----- CosNotifyChannelAdmin::SequenceProxyPullSupplier ----%%----------------------------------------------------------%%% function : connect_sequence_pull_consumer%% Arguments: Client - CosNotifyComm::SequencePullConsumer%% Returns  :  ok | {'EXCEPTION', #'AlreadyConnected'{}} |%%            {'EXCEPTION', #'TypeError'{}} |%%            {'EXCEPTION', #'BAD_OPERATION'{}}%%-----------------------------------------------------------connect_sequence_pull_consumer(_OE_THIS, _OE_FROM, State, Client) when ?is_SEQUENCE(State) ->    ?not_TypeCheck(Client, 'CosNotifyComm_SequencePullConsumer'),    if	?is_Connected(State) ->	    corba:raise(#'CosEventChannelAdmin_AlreadyConnected'{});	true ->	    {reply, ok, ?set_Client(State, Client)}    end;connect_sequence_pull_consumer(_, _, _, _) ->    corba:raise(#'BAD_OPERATION'{completion_status=?COMPLETED_NO}).%%----- CosNotifyChannelAdmin::StructuredProxyPullSupplier --%%----------------------------------------------------------%%% function : connect_structured_pull_consumer%% Arguments: Client - CosNotifyComm::StructuredPullConsumer%% Returns  :  ok | {'EXCEPTION', #'AlreadyConnected'{}} |%%            {'EXCEPTION', #'TypeError'{}} |%%            {'EXCEPTION', #'BAD_OPERATION'{}}%%-----------------------------------------------------------connect_structured_pull_consumer(_OE_THIS, _OE_FROM, State, Client) when ?is_STRUCTURED(State) ->    ?not_TypeCheck(Client, 'CosNotifyComm_StructuredPullConsumer'),    if	?is_Connected(State) ->	    corba:raise(#'CosEventChannelAdmin_AlreadyConnected'{});	true ->	    {reply, ok, ?set_Client(State, Client)}    end;connect_structured_pull_consumer(_, _, _, _) ->    corba:raise(#'BAD_OPERATION'{completion_status=?COMPLETED_NO}).%%----- Inherit from CosNotifyChannelAdmin::ProxySupplier ---%%----------------------------------------------------------%%% function : obtain_offered_types%% Arguments: Mode - enum 'ObtainInfoMode' (CosNotifyChannelAdmin)%% Returns  : CosNotification::EventTypeSeq%%-----------------------------------------------------------obtain_offered_types(_OE_THIS, _OE_FROM, State, 'ALL_NOW_UPDATES_OFF') ->    {reply, ?get_AllSubscribe(State), ?set_SubscribeType(State, false)};obtain_offered_types(_OE_THIS, _OE_FROM, State, 'ALL_NOW_UPDATES_ON') ->    {reply, ?get_AllSubscribe(State), ?set_SubscribeType(State, true)};obtain_offered_types(_OE_THIS, _OE_FROM, State, 'NONE_NOW_UPDATES_OFF') ->    {reply, [], ?set_SubscribeType(State, false)};obtain_offered_types(_OE_THIS, _OE_FROM, State, 'NONE_NOW_UPDATES_ON') ->    {reply, [], ?set_SubscribeType(State, true)};obtain_offered_types(_,_,_,What) ->    orber:dbg("[~p] PullerSupplier:obtain_offered_types(~p);~n"	      "Incorrect enumerant", [?LINE, What], ?DEBUG_LEVEL),    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).%%----------------------------------------------------------%%% function : validate_event_qos%% Arguments: RequiredQoS - CosNotification::QoSProperties%% Returns  : ok | {'EXCEPTION', #'UnsupportedQoS'{}}%%            AvilableQoS - CosNotification::NamedPropertyRangeSeq (out)%%-----------------------------------------------------------validate_event_qos(_OE_THIS, _OE_FROM, State, RequiredQoS) ->    AvilableQoS = 'CosNotification_Common':validate_event_qos(RequiredQoS,							      ?get_LocalQoS(State)),    {reply, {ok, AvilableQoS}, State}.%%----- Inherit from CosNotification::QoSAdmin --------------%%----------------------------------------------------------%%% function : get_qos%% Arguments: %% Returns  : %%-----------------------------------------------------------get_qos(_OE_THIS, _OE_FROM, State) ->    {reply, ?get_GlobalQoS(State), State}.    %%----------------------------------------------------------%%% function : set_qos%% Arguments: QoS - CosNotification::QoSProperties, i.e.,%%            [#'Property'{name, value}, ...] where name eq. string()%%            and value eq. any().%% Returns  : ok | {'EXCEPTION', CosNotification::UnsupportedQoS}%%-----------------------------------------------------------set_qos(_OE_THIS, _OE_FROM, State, QoS) ->    {NewQoS, LQS} = 'CosNotification_Common':set_qos(QoS, ?get_BothQoS(State), 						     proxy, ?get_MyAdmin(State), 						     false),    NewState = ?update_EventDB(State, LQS),    {reply, ok, ?set_BothQoS(NewState, NewQoS, LQS)}.%%----------------------------------------------------------%%% function : validate_qos%% Arguments: Required_qos - CosNotification::QoSProperties%%            [#'Property'{name, value}, ...] where name eq. string()%%            and value eq. any().%% Returns  : {'EXCEPTION', CosNotification::UnsupportedQoS}%%            {ok, CosNotification::NamedPropertyRangeSeq}%%-----------------------------------------------------------validate_qos(_OE_THIS, _OE_FROM, State, Required_qos) ->    QoS = 'CosNotification_Common':validate_qos(Required_qos, ?get_BothQoS(State), 						proxy, ?get_MyAdmin(State), 						false),    {reply, {ok, QoS}, State}.%%----- Inherit from CosNotifyComm::NotifySubscribe ---------%%----------------------------------------------------------%%% function : subscription_change%% Arguments: Added - Removed - CosNotification::EventTypeSeq%% Returns  : ok%%-----------------------------------------------------------subscription_change(_OE_THIS, _OE_FROM, State, Added, Removed) ->    cosNotification_Filter:validate_types(Added),     cosNotification_Filter:validate_types(Removed),    %% On this "side", we care about which type of events the client     %% will require, since the client (or an agent) clearly stated    %% that it's only interested in these types of events.    %% Also see PusherConsumer- and PullerConsumer-'offer_change'.    update_subscribe(remove, State, Removed),    CurrentSub = ?get_AllSubscribe(State),    NewState = 	case cosNotification_Filter:check_types(Added++CurrentSub) of	    true ->		%% Types supplied does in some way cause all events to be valid.		%% Smart? Would have been better to not supply any at all.		?set_SubscribeData(State, true);	    {ok, Which, WC} ->		?set_SubscribeData(State, {Which, WC})    end,    update_subscribe(add, NewState, Added),    case ?get_SubscribeType(NewState) of	true ->	    %% Perhaps we should handle exception here?!	    %% Probably not. Better to stay "on-line".	    catch 'CosNotifyComm_NotifyPublish':		offer_change(?get_Client(NewState), Added, Removed),	    ok;	_->	    ok    end,	    {reply, ok, NewState}.update_subscribe(_, _, [])->    ok;update_subscribe(add, State, [H|T]) ->    ?add_Subscribe(State, H),    update_subscribe(add, State, T);update_subscribe(remove, State, [H|T]) ->    ?del_Subscribe(State, H),    update_subscribe(remove, State, T).%%----- Inherit from CosNotifyFilter::FilterAdmin -----------%%----------------------------------------------------------%%% function : add_filter%% Arguments: Filter - CosNotifyFilter::Filter%% Returns  : FilterID - long%%-----------------------------------------------------------add_filter(_OE_THIS, _OE_FROM, State, Filter) ->    'CosNotification_Common':type_check(Filter, 'CosNotifyFilter_Filter'),    FilterID = ?new_Id(State),    NewState = ?set_IdCounter(State, FilterID),    {reply, FilterID, ?add_Filter(NewState, FilterID, Filter)}.%%----------------------------------------------------------%%% function : remove_filter%% Arguments: FilterID - long%% Returns  : ok%%-----------------------------------------------------------remove_filter(_OE_THIS, _OE_FROM, State, FilterID) when integer(FilterID) ->    {reply, ok, ?del_Filter(State, FilterID)};remove_filter(_,_,_,What) ->    orber:dbg("[~p] PullerSupplier:remove_filter(~p); Not an integer", 	      [?LINE, What], ?DEBUG_LEVEL),    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).%%----------------------------------------------------------%%% function : get_filter%% Arguments: FilterID - long%% Returns  : Filter - CosNotifyFilter::Filter |%%            {'EXCEPTION', #'CosNotifyFilter_FilterNotFound'{}}%%-----------------------------------------------------------get_filter(_OE_THIS, _OE_FROM, State, FilterID) when integer(FilterID) ->    {reply, ?get_Filter(State, FilterID), State};get_filter(_,_,_,What) ->    orber:dbg("[~p] PullerSupplier:get_filter(~p); Not an integer", 	      [?LINE, What], ?DEBUG_LEVEL),    corba:raise(#'BAD_PARAM'{completion_status=?COMPLETED_NO}).%%----------------------------------------------------------%%% function : get_all_filters%% Arguments: -%% Returns  : Filter - CosNotifyFilter::FilterIDSeq%%-----------------------------------------------------------get_all_filters(_OE_THIS, _OE_FROM, State) ->    {reply, ?get_AllFilterID(State), State}.%%----------------------------------------------------------%%% function : remove_all_filters%% Arguments: -%% Returns  : ok%%-----------------------------------------------------------remove_all_filters(_OE_THIS, _OE_FROM, State) ->    {reply, ok, ?del_AllFilter(State)}.%%----- Inherit from CosEventComm::PullSupplier -------------%%----------------------------------------------------------%%% function : disconnect_pull_supplier%% Arguments: -%% Returns  : ok%%-----------------------------------------------------------disconnect_pull_supplier(_OE_THIS, _OE_FROM, State) ->    {stop, normal, ok, ?set_Unconnected(State)}.%%----------------------------------------------------------%%% function : pull%% Arguments: -%% Returns  : any - CORBA::ANY%%-----------------------------------------------------------pull(_OE_THIS, OE_FROM, State) when ?is_ANY(State) ->    case ?get_Event(State) of	{[], _} ->	    {noreply, ?set_RespondTo(State, OE_FROM)};	{Event,_} ->	    {reply, Event, State}    end;pull(_,_,_) ->    corba:raise(#'BAD_OPERATION'{completion_status=?COMPLETED_NO}).%%----------------------------------------------------------%%% function : try_pull%% Arguments: -%% Returns  : any - CORBA::ANY

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?