--  Copyright (2008-2013) Cédric Coussinet (cedric.coussinet@nomoseed.net)
--
--  This program is free software: you can redistribute it and/or modify
--  it under the terms of the GNU Affero General Public License as published
--  by the Free Software Foundation, either version 3 of the License, or
--  (at your option) any later version.
--
--  This program is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--  GNU Affero General Public License for more details.

--  You should have received a copy of the GNU Affero General Public License
--  along with this program. If not, see <http://www.gnu.org/licenses/>

with Nomo.Numerics.Times;

with Nomo.Numerics.Accurately;

private with Nomo.Interpreter.Types_Index.Ranges;

private with Nomo.Interpreter.Beginning.Parameters;
pragma Elaborate_All (Nomo.Interpreter.Beginning.Parameters);

private with Nomo.Interpreter.Activations_Memories;
pragma Elaborate_All (Nomo.Interpreter.Activations_Memories);

private with Nomo.Interpreter.Gen_Clusters_Base;
pragma Elaborate_All (Nomo.Interpreter.Gen_Clusters_Base);

private with Nomo.Interpreter.Perception_Rules;

private package Nomo.Interpreter.Perceptions_Clusters is

   use Numerics.Times;
   use Numerics.Accurately;

   type Perceptions_Cluster is tagged limited private;

   procedure Assume (This : in out Perceptions_Cluster;
                     T    : in Positive_Time);

   function Has_Selection (This : in Perceptions_Cluster) return Boolean;
   pragma Inline (Has_Selection);

   procedure Interpret (This : in out Perceptions_Cluster);

   procedure Reinforce (This            : in out Perceptions_Cluster;
                        T               : in Positive_Time;
                        First_Landmark  : in Positive_Time_Interval;
                        Second_Landmark : in Positive_Time_Interval;
                        Quantity        : in Real_Accurately_0_To_1);
   pragma Inline (Reinforce);

private

   use Types_Index.Ranges;
   use Perception_Rules;

   type Perceptive_Rule_Ptr is access all Perception_Rule;

   package Perceptions_Clusters_Base is new Gen_Clusters_Base (Perception_Rule,
                                                               Perceptive_Rule_Ptr,
                                                               Beginning.Parameters.Get_Maximum_Of_Rules_By_Type,
                                                               Adjust,
                                                               Evaluate,
                                                               Evaluate,
                                                               Is_Forget,
                                                               Is_Updatable,
                                                               Update_Relevance,
                                                               Update_Relevance);
   use Perceptions_Clusters_Base;

   package Activations_Perceptions_Memories is new Activations_Memories (Perception_Rule,
                                                                         Perceptive_Rule_Ptr,
                                                                         Reinforce);
   use Activations_Perceptions_Memories;

   type Perceptions_Cluster is new Cluster_Base with record
      Activations     : Activations_Memory;
      Perception_Type : Perception_Type_Index;
      Input_Type      : Input_Type_Index;
   end record;

end Nomo.Interpreter.Perceptions_Clusters;
