Skip to content

Commit

Permalink
M agpl-conversions.adb
Browse files Browse the repository at this point in the history
M    agpl-conversions.ads
M    agpl-protected_datastore.ads
M    agpl-optimization-annealing-solver.adb
M    agpl-strings.adb
M    agpl-strings.ads
M    agpl-cr-plan_assigner-greedy1.adb
M    agpl-cr-agent.adb
M    agpl-cr-mutable_assignment.adb
D    agpl-conversions-io.adb
D    agpl-conversions-io.ads
M    agpl-cr-gap.adb
M    agpl-task_termination.adb
M    agpl-task_termination.ads
  • Loading branch information
mosteo committed Jul 25, 2006
1 parent ba0edf9 commit 9437bdb
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 149 deletions.
71 changes: 0 additions & 71 deletions agpl-conversions-io.adb

This file was deleted.

57 changes: 0 additions & 57 deletions agpl-conversions-io.ads

This file was deleted.

29 changes: 29 additions & 0 deletions agpl-conversions.adb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ with Ada.Strings.fixed;

with Interfaces;

with System.Img_Real; use System.Img_Real;

package body Agpl.Conversions is

------------------------------------------------------------------------
Expand Down Expand Up @@ -118,6 +120,33 @@ package body Agpl.Conversions is
return Trim (Integer'Image (N));
end To_string;

function To_String (N : Float; Decimals : Natural := 2) return String is
begin
return To_String (Long_Long_Float (N), Decimals);
end To_string;

function To_String (N : Long_Long_Float; Decimals : Natural := 2) return String is
begin
if Decimals > 0 then
return Trim (Image_Ordinary_Fixed_Point (N, Decimals));
else
return To_String (Integer (N));
end if;
end To_string;

------------
-- To_Str --
------------

function To_Str (N : Real; Decimals : Natural := 2) return String is
begin
if Decimals > 0 then
return To_String (Long_Long_Float (N), Decimals);
else
return To_String (Integer (N));
end if;
end To_Str;

------------------------------------------------------------------------
-- Trim --
------------------------------------------------------------------------
Expand Down
16 changes: 16 additions & 0 deletions agpl-conversions.ads
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ package Agpl.Conversions is

function To_String (N : Integer) return String;

-- Works as 'Img but removes leading/trailing spaces
-- Performs rounding on floats
function To_string (N : Float;
Decimals : Natural := 2)
return String;

function To_string (N : Long_Long_Float;
Decimals : Natural := 2)
return String;

generic
type Real is digits <>;
function To_Str (N : Real;
Decimals : Natural := 2)
return String;

function Trim (This : in String) return String;
pragma Inline (Trim);

Expand Down
2 changes: 1 addition & 1 deletion agpl-cr-agent.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
with Agpl.Conversions.Io; use Agpl.Conversions.Io;
with Agpl.Conversions; use Agpl.Conversions;
with Agpl.Cr.Tasks.Starting_Pose;
with Agpl.Trace; use Agpl.Trace;

Expand Down
2 changes: 1 addition & 1 deletion agpl-cr-gap.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
with Agpl.Conversions.Io; use Agpl.Conversions.Io;
with Agpl.Conversions; use Agpl.Conversions;
with Agpl.Text_Io;

package body Agpl.Cr.Gap is
Expand Down
7 changes: 3 additions & 4 deletions agpl-cr-mutable_assignment.adb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

-- This one strives to be a really general, problem-independent solution.

with Agpl.Conversions.Io; pragma Elaborate_All (Agpl.Conversions.Io);
use Agpl.Conversions.Io;
with Agpl.Conversions;
use Agpl.Conversions;
with Agpl.Cr.Agent.Dummy;
with Agpl.Cr.Agent.Lists;
with Agpl.Cr.Assigner.Hungry3;
Expand Down Expand Up @@ -60,7 +60,7 @@ package body Agpl.Cr.Mutable_Assignment is
No_Task : Htn.Tasks.Task_Id renames Htn.Tasks.No_Task;

function S is new
Conversions.Io.To_Str (Optimization.Annealing.Probability);
Conversions.To_Str (Optimization.Annealing.Probability);

function "<" (L, R : Minimax_Key) return Boolean is
use Asu;
Expand Down Expand Up @@ -535,7 +535,6 @@ package body Agpl.Cr.Mutable_Assignment is
Ada.Numerics.Generic_Elementary_Functions
(Optimization.Annealing.Acceptability);

use Conversions;
use Optimization; use Annealing;
use Acceptability_Math;
begin
Expand Down
2 changes: 1 addition & 1 deletion agpl-cr-plan_assigner-greedy1.adb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
-- An assigner creates assignments. Ideally it should aim to achieve some kind
-- of optimality.

-- with Agpl.Conversions.Io; use Agpl.Conversions.Io;
-- with Agpl.Conversions; use Agpl.Conversions;
with Agpl.Cr.Tasks.Insertions;
with Agpl.Htn.Plan_Node;
with Agpl.Htn.Plan.Utils;
Expand Down
2 changes: 1 addition & 1 deletion agpl-optimization-annealing-solver.adb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
------------------------------------------------------------------------------

with Agpl.Chronos;
with Agpl.Conversions.Io; use Agpl.Conversions.Io;
with Agpl.Conversions; use Agpl.Conversions;
with Agpl.Cr;
with Agpl.Trace; use Agpl.Trace;

Expand Down
2 changes: 2 additions & 0 deletions agpl-protected_datastore.ads
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ package Agpl.Protected_Datastore is
Listener : not null Key_Listener_Access);
-- Register for a key

pragma Incomplete ("Should have unlisten equivalent!");

private

package Listener_Vectors is new Ada.Containers.Vectors
Expand Down
8 changes: 0 additions & 8 deletions agpl-strings.adb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ package body Agpl.Strings is
return Ada.Characters.Handling.To_upper (This);
end To_upper;

------------------------------------------------------------------------
-- Trim --
------------------------------------------------------------------------
function Trim (This : in String) return String is
begin
return Ada.Strings.Fixed.Trim (This, Ada.Strings.Both);
end Trim;

------------------------------------------------------------------------
-- Lpad --
------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions agpl-strings.ads
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ package Agpl.Strings is
------------------------------------------------------------------------
-- Trim --
------------------------------------------------------------------------
function Trim (This : in String) return String;
pragma Inline (Trim);

function Trim (This : in String) return String
renames Conversions.Trim;

end Agpl.Strings;
4 changes: 2 additions & 2 deletions agpl-task_termination.adb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ package body Agpl.Task_Termination is
begin
Log ("Grim reaper: Task [" & Image (T) & "] finished with cause " &
Cause_Of_Termination'Image (Cause),
Levels (Cause));
Levels (Cause), Log_Section);
if Cause = Unhandled_Exception then
Log ("Grim reaper: Task [" & Image (T) & "] exception was " &
Trace.Report (X),
Levels (Cause));
Levels (Cause), Log_Section);
end if;
end Grim_Reaper;
end Object;
Expand Down
2 changes: 2 additions & 0 deletions agpl-task_termination.ads
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package Agpl.Task_Termination is

pragma Elaborate_Body;

Log_Section : constant String := "agpl.task_termination";

-- To with this package will cause the installation of a default termination
-- handler that will task terminations via Agpl.Trace.
-- Normal terminations will be reported at debug level,
Expand Down

0 comments on commit 9437bdb

Please sign in to comment.