-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roger Mc Murtrie
committed
Nov 23, 2017
1 parent
5af40bf
commit fd6284a
Showing
3 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
with Ada.Containers.Doubly_Linked_Lists; | ||
|
||
package body Silo is | ||
use Ada.Containers; | ||
|
||
package Label_Container is new Doubly_Linked_Lists (Label_Data); | ||
type Label_List is new Label_Container.List with null record; | ||
|
||
theStack : Label_List; | ||
|
||
procedure Push (Data : Label_Data) is | ||
begin | ||
Append (theStack, Data); | ||
end Push; | ||
|
||
-- ----------------------------------------------------------------- | ||
|
||
function Pull return Label_Data is | ||
Data : Label_Data; | ||
begin | ||
if Is_Empty (theStack) then | ||
raise Empty_Stack; | ||
end if; | ||
|
||
Data := First_Element (theStack); | ||
Delete_First (theStack); | ||
return Data; | ||
end Pull; | ||
|
||
-- ----------------------------------------------------------------- | ||
|
||
function Set_Data (Label_String : Unbounded_String; | ||
Label_Position : GL.Types.Singles.Vector2) | ||
return Label_Data is | ||
begin | ||
return (Label_String, Label_Position); | ||
end Set_Data; | ||
|
||
-- ----------------------------------------------------------------- | ||
|
||
procedure Get_Data (Label_String : out Unbounded_String; | ||
Label_Position : out GL.Types.Singles.Vector2) is | ||
theData : Label_Data := Pull; | ||
begin | ||
Label_String:= theData.Label_String; | ||
Label_Position := theData.Label_Position; | ||
end Get_Data; | ||
|
||
-- ----------------------------------------------------------------- | ||
function Size return Integer is | ||
begin | ||
return Integer (Length (theStack)); | ||
end Size; | ||
|
||
-- ----------------------------------------------------------------- | ||
|
||
end Silo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; | ||
|
||
with GL.Types; | ||
|
||
package Silo is | ||
|
||
type Label_Data is private; | ||
|
||
Empty_Stack : Exception; | ||
|
||
procedure Get_Data (Label_String : out Unbounded_String; | ||
Label_Position : out GL.Types.Singles.Vector2); | ||
procedure Push (Data : Label_Data); | ||
function Pull return Label_Data; | ||
function Set_Data (Label_String : Unbounded_String; | ||
Label_Position : GL.Types.Singles.Vector2) | ||
return Label_Data; | ||
function Size return Integer; | ||
|
||
private | ||
type Label_Data is record | ||
Label_String : Unbounded_String; | ||
Label_Position : GL.Types.Singles.Vector2; | ||
end record; | ||
|
||
end Silo; |