Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/Singleton/Ada/singleton-1.ada
Normal file
10
Task/Singleton/Ada/singleton-1.ada
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package Global_Singleton is
|
||||
procedure Set_Data (Value : Integer);
|
||||
function Get_Data return Integer;
|
||||
private
|
||||
type Instance_Type is record
|
||||
-- Define instance data elements
|
||||
Data : Integer := 0;
|
||||
end record;
|
||||
Instance : Instance_Type;
|
||||
end Global_Singleton;
|
||||
21
Task/Singleton/Ada/singleton-2.ada
Normal file
21
Task/Singleton/Ada/singleton-2.ada
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package body Global_Singleton is
|
||||
|
||||
--------------
|
||||
-- Set_Data --
|
||||
--------------
|
||||
|
||||
procedure Set_Data (Value : Integer) is
|
||||
begin
|
||||
Instance.Data := Value;
|
||||
end Set_Data;
|
||||
|
||||
--------------
|
||||
-- Get_Data --
|
||||
--------------
|
||||
|
||||
function Get_Data return Integer is
|
||||
begin
|
||||
return Instance.Data;
|
||||
end Get_Data;
|
||||
|
||||
end Global_Singleton;
|
||||
11
Task/Singleton/Ada/singleton-3.ada
Normal file
11
Task/Singleton/Ada/singleton-3.ada
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package Protected_Singleton is
|
||||
procedure Set_Data (Value : Integer);
|
||||
function Get_Data return Integer;
|
||||
private
|
||||
protected Instance is
|
||||
procedure Set(Value : Integer);
|
||||
function Get return Integer;
|
||||
private
|
||||
Data : Integer := 0;
|
||||
end Instance_Type;
|
||||
end Protected_Singleton;
|
||||
47
Task/Singleton/Ada/singleton-4.ada
Normal file
47
Task/Singleton/Ada/singleton-4.ada
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package body Protected_Singleton is
|
||||
|
||||
--------------
|
||||
-- Set_Data --
|
||||
--------------
|
||||
|
||||
procedure Set_Data (Value : Integer) is
|
||||
begin
|
||||
Instance.Set(Value);
|
||||
end Set_Data;
|
||||
|
||||
--------------
|
||||
-- Get_Data --
|
||||
--------------
|
||||
|
||||
function Get_Data return Integer is
|
||||
begin
|
||||
return Instance.Get;
|
||||
end Get_Data;
|
||||
|
||||
--------------
|
||||
-- Instance --
|
||||
--------------
|
||||
|
||||
protected body Instance is
|
||||
|
||||
---------
|
||||
-- Set --
|
||||
---------
|
||||
|
||||
procedure Set (Value : Integer) is
|
||||
begin
|
||||
Data := Value;
|
||||
end Set;
|
||||
|
||||
---------
|
||||
-- Get --
|
||||
---------
|
||||
|
||||
function Get return Integer is
|
||||
begin
|
||||
return Data;
|
||||
end Get;
|
||||
|
||||
end Instance;
|
||||
|
||||
end Protected_Singleton;
|
||||
Loading…
Add table
Add a link
Reference in a new issue