1 | :- module(module_information,[module_info/2,module_info/3,get_module_info/3, | |
2 | number_of_groups/1,number_of_modules/1,number_of_modules/2, | |
3 | get_module_group/1]). | |
4 | ||
5 | % a simple mechanism to provide annotations for various modules | |
6 | % examples: | |
7 | % :- module_info(description,'....'). | |
8 | % :- module_info(group,kernel). | |
9 | :- meta_predicate module_info(:,*). | |
10 | :- dynamic get_module_info/3. | |
11 | :- if(predicate_property(current_logtalk_flag(_, _), _)). | |
12 | module_info(Attribute,Value) :- | |
13 | sender(Module), | |
14 | assertz(get_module_info(Module,Attribute,Value)). | |
15 | :- else. | |
16 | module_info(Module:Attribute,Value) :- | |
17 | assertz(get_module_info(Module,Attribute,Value)). | |
18 | :- endif. | |
19 | % called for non-module prolog files | |
20 | module_info(Module,Attribute,Value) :- | |
21 | assertz(get_module_info(Module,Attribute,Value)). | |
22 | ||
23 | :- module_info(group,infrastructure). | |
24 | :- module_info(description,'This module contains functionality to store basic documentation and information about all modules in ProB.'). | |
25 | ||
26 | :- use_module(library(lists)). | |
27 | ||
28 | number_of_groups(X) :- | |
29 | findall(Group,get_module_info(_Module,group,Group),List), | |
30 | remove_dups(List,NList), | |
31 | length(NList,X). | |
32 | ||
33 | number_of_modules(X) :- | |
34 | findall(Module,get_module_info(Module,_A,_B),List), | |
35 | remove_dups(List,NList), | |
36 | length(NList,X). | |
37 | ||
38 | number_of_modules(Group,X) :- | |
39 | findall(Module,get_module_info(Module,group,Group),List), | |
40 | remove_dups(List,NList), | |
41 | length(NList,X). | |
42 | ||
43 | get_module_group(X) :- | |
44 | findall(Group,get_module_info(_Module,group,Group),List), | |
45 | remove_dups(List,NList), | |
46 | member(X,NList). |