해시 된지도를 보호 된 개체로 래핑하여 여러 작업을 통해 액세스 할 수 있습니다. 보호 된 유형의 프로 시저를 사용할 수있게하려고하지만 해시 맵과 요소 레코드 정의를 패키지 개인 섹션으로 이동하는 것이 좋습니다. 여기Ada의 보호 된 개체에서 개인 형식 액세스
예제 코드 :
package Thing_Protected is
type Thing_Info is record
Key : Ada.Strings.Unbounded.Unbounded_String;
Counter_Value : Natural := 0;
end record;
package Thing_Info_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => Thing_Info,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => Ada.Strings.Unbounded."=");
protected type Thing is
procedure Increment (Key : String);
procedure Another_Thing (Key : String);
private
Thing_Map : Thing_Info_Maps.Map;
end Thing;
private
-- move Thing_Info, Thing_info_maps into here.
end Thing_Protected;
나는 개인 유형으로 Thing_Info을 정의하려고했습니다 ..하지만 난 개인으로 Thing_Info_Maps 패키지를 정의 할 방법을 잘 모르겠어요하지만 여전히 보호 오브젝트에서 액세스 유형.
그래서 정말 이런 식으로 뭔가를 얻을 수있는 방법을 찾기 위해 노력하고 찾을 수없는 것 :
package Thing_Protected is
type Thing_Info is private;
package Thing_Info_Maps is private;
protected type Thing is
procedure Increment (Key : String);
procedure Another_Thing (Key : String);
private
Thing_Map : Thing_Info_Maps.Map; -- <<- how would we know about .Map??
end Thing;
private
type Thing_Info is record
Key : Ada.Strings.Unbounded.Unbounded_String;
Counter_Value : Natural := 0;
end record;
package Thing_Info_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Ada.Strings.Unbounded.Unbounded_String,
Element_Type => Thing_Info,
Hash => Ada.Strings.Unbounded.Hash,
Equivalent_Keys => Ada.Strings.Unbounded."=");
end Thing_Protected;
처럼. "[제목에"태그 "가 포함되어 있어야합니까?] (http://meta.stackexchange.com/questions/19190/)"합의가 "아니오, 그렇지 않아야합니다"로 표시되어야합니다. –
나는 그것이 ada와 관련이 있다는 것이 명백하지는 않다고 생각한다. 특히 'ada'라는 태그가 붙은 상위 15 개 투표 결과가 있었기 때문에 제목에 Ada가 하나도 없었습니다. –
나는 그것을 돌볼 것이다. –