1%%-------------------------------------------------------------------- 2%% 3%% %CopyrightBegin% 4%% 5%% Copyright Ericsson AB 1997-2016. All Rights Reserved. 6%% 7%% Licensed under the Apache License, Version 2.0 (the "License"); 8%% you may not use this file except in compliance with the License. 9%% You may obtain a copy of the License at 10%% 11%% http://www.apache.org/licenses/LICENSE-2.0 12%% 13%% Unless required by applicable law or agreed to in writing, software 14%% distributed under the License is distributed on an "AS IS" BASIS, 15%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16%% See the License for the specific language governing permissions and 17%% limitations under the License. 18%% 19%% %CopyrightEnd% 20%% 21%% 22%%----------------------------------------------------------------- 23%% File: lname_component.erl 24%%----------------------------------------------------------------- 25-module(lname_component). 26 27-include_lib("orber/include/corba.hrl"). 28-include("lname.hrl"). 29-include("CosNaming.hrl"). 30 31%%----------------------------------------------------------------- 32%% External exports 33%%----------------------------------------------------------------- 34-export([get_id/1, set_id/2, get_kind/1, set_kind/2, create/0, new/1, new/2]). 35 36%%----------------------------------------------------------------- 37%% Internal exports 38%%----------------------------------------------------------------- 39-export([]). 40 41%%----------------------------------------------------------------- 42%% External interface functions 43%%----------------------------------------------------------------- 44create() -> 45 #'CosNaming_NameComponent'{id="", kind=""}. 46 47get_id(NC) when is_record(NC, 'CosNaming_NameComponent'), 48 NC#'CosNaming_NameComponent'.id == undefined -> 49 corba:raise(#'LNameComponent_NotSet'{}); 50get_id(NC) when is_record(NC, 'CosNaming_NameComponent'), 51 NC#'CosNaming_NameComponent'.id == "" -> 52 corba:raise(#'LNameComponent_NotSet'{}); 53get_id(NC) when is_record(NC, 'CosNaming_NameComponent') -> 54 NC#'CosNaming_NameComponent'.id. 55 56set_id(NC, Id) when is_record(NC, 'CosNaming_NameComponent') andalso is_list(Id)-> 57 NC#'CosNaming_NameComponent'{id=Id}. 58 59get_kind(NC) when is_record(NC, 'CosNaming_NameComponent') andalso 60 NC#'CosNaming_NameComponent'.kind == undefined -> 61 corba:raise(#'LNameComponent_NotSet'{}); 62get_kind(NC) when is_record(NC, 'CosNaming_NameComponent') andalso 63 NC#'CosNaming_NameComponent'.kind == "" -> 64 corba:raise(#'LNameComponent_NotSet'{}); 65get_kind(NC) when is_record(NC, 'CosNaming_NameComponent') -> 66 NC#'CosNaming_NameComponent'.kind. 67 68set_kind(NC, Kind) when is_record(NC, 'CosNaming_NameComponent') andalso is_list(Kind) -> 69 NC#'CosNaming_NameComponent'{kind=Kind}. 70 71%%destroy() -> % not needed in erlang 72%% true. 73 74%%----------------------------------------------------------------- 75%% External Functions not in the CosNaming standard 76%%----------------------------------------------------------------- 77new(Id) when is_list(Id) -> 78 #'CosNaming_NameComponent'{id=Id, kind=""}. 79new(Id, Kind) when is_list(Id) andalso is_list(Kind) -> 80 #'CosNaming_NameComponent'{id=Id, kind=Kind}. 81 82%%----------------------------------------------------------------- 83%% Internal Functions 84%%----------------------------------------------------------------- 85