1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--       OCARINA.INSTANCES.REAL_CHECKER.QUERIES.CONNECTED_PREDICATES        --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--                  Copyright (C) 2009 Telecom ParisTech,                   --
10
--                 2010-2019 ESA & ISAE, 2019-2020 OpenAADL                 --
11
--                                                                          --
12
-- Ocarina  is free software; you can redistribute it and/or modify under   --
13
-- terms of the  GNU General Public License as published  by the Free Soft- --
14
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
15
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
16
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
17
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
18
--                                                                          --
19
-- As a special exception under Section 7 of GPL version 3, you are granted --
20
-- additional permissions described in the GCC Runtime Library Exception,   --
21
-- version 3.1, as published by the Free Software Foundation.               --
22
--                                                                          --
23
-- You should have received a copy of the GNU General Public License and    --
24
-- a copy of the GCC Runtime Library Exception along with this program;     --
25
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
26
-- <http://www.gnu.org/licenses/>.                                          --
27
--                                                                          --
28
--                    Ocarina is maintained by OpenAADL team                --
29
--                              (info@openaadl.org)                         --
30
--                                                                          --
31
------------------------------------------------------------------------------
32

33
with Ocarina.ME_AADL.AADL_Instances.Nodes;
34
with Ocarina.ME_AADL.AADL_Instances.Nutils;
35

36
package body Ocarina.Instances.REAL_Checker.Queries.Connected_Predicates is
37
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
38
   package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
39

40 1
   function Is_Connected_Predicate
41
     (E      : Node_Id;
42
      D      : Node_Id;
43
      Option : Predicates_Search_Options := PSO_Direct) return Boolean
44
   is
45
      pragma Unreferenced (Option);
46

47 1
      N : Node_Id;
48
   begin
49 1
      if Kind (E) /= K_Component_Instance
50 1
        or else Kind (D) /= K_Component_Instance
51
      then
52 0
         return False;
53
      end if;
54

55 1
      if AINU.Is_Empty (Features (E)) then
56 0
         return False;
57
      end if;
58

59
      --  Returns true if the current node is connected to the parameter
60
      --  component.
61

62 1
      N := First_Node (Features (E));
63 1
      while Present (N) loop
64
         declare
65 1
            S : Node_Id := First_Node (Destinations (N));
66 1
            M : Node_Id;
67 1
            P : Node_Id;
68
         begin
69 1
            while Present (S) loop
70
               case Kind (Item (S)) is
71

72
                  when K_Port_Spec_Instance =>
73 1
                     M := S;
74 1
                     while Present (M) loop
75

76 1
                        P := Parent_Component (Item (M));
77 1
                        if P = D then
78 1
                           return True;
79
                        end if;
80

81 1
                        M := First_Node (Destinations (Item (M)));
82 1
                     end loop;
83

84
                  when others =>
85 1
                     null;
86
               end case;
87

88 1
               S := Next_Node (S);
89 1
            end loop;
90
         end;
91

92 1
         N := Next_Node (N);
93 1
      end loop;
94

95 1
      return False;
96

97
   end Is_Connected_Predicate;
98

99
end Ocarina.Instances.REAL_Checker.Queries.Connected_Predicates;

Read our documentation on viewing source code .

Loading