% Copyright (C) 2003 Fred Mesnard <fred@univ-reunion.fr>
%
% This file is part of cTI.
%
% cTI is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2 of the License, or (at your
% option) any later version.
%
% cTI 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 General Public License
% for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
% USA.
%
% For the most up-to-date information see the cTI's web site:
% http://www.cs.unipr.it/cTI/

/*
The following flag is set up by main.pl:
current_cti_flag(poly_lib,LIB) with LIB=poly_ppl %or LIB=poly_clpq
*/
current_cti_flag(cTI_version,'1.0').
current_cti_flag(process_include_ensure_loaded,off).
current_cti_flag(time_out,2000).  % = 2 seconds
current_cti_flag(nb_ite_clpn,1).
%current_cti_flag(compare_ppl_clpq,off).
current_cti_flag(known_predicate,PI) :-
	(var(PI) ->
	    predef(Atom),
	    functor(Atom,P,N),
	    PI=P/N
	;
	    (ground(PI) ->
		PI=P/N,
		functor(Atom,P,N),
		predef(Atom))).

set_cti_flag(X,_) :- var(X),!,fail.
set_cti_flag(time_out,V) :-
	integer(V), V >= 10, !, % min for timeout
	retract(current_cti_flag(time_out,_)),!,
	assert(current_cti_flag(time_out,V)).
set_cti_flag(nb_ite_clpn,V) :-
	integer(V), V >= 1, !,
	retract(current_cti_flag(nb_ite_clpn,_)),!,
	assert(current_cti_flag(nb_ite_clpn,V)).
%set_cti_flag(compare_ppl_clpq,V) :-
%	(V==on ; V==off),!,
%	retract(current_cti_flag(compare_ppl_clpq,_)),!,
%	assert(current_cti_flag(compare_ppl_clpq,V)).
set_cti_flag(process_include_ensure_loaded,V) :-
	(V==on ; V==off),!,
	retract(current_cti_flag(process_include_ensure_loaded,_)),!,
	assert(current_cti_flag(process_include_ensure_loaded,V)).
%%% set_cti_flag(poly_lib,V) :-
%%% 	V==poly_ppl,!,
%%% 	current_cti_flag(poly_lib,OldValue),
%%% 	switch_to_ppl(OldValue).
%%% set_cti_flag(poly_lib,V) :-
%%% 	V==poly_clpq,!,
%%% 	current_cti_flag(poly_lib,OldValue),
%%% 	switch_to_clpq(OldValue).

%%% % switch_to_???(OldLib)
%%% switch_to_ppl(poly_ppl).
%%% switch_to_ppl(poly_clpq) :-
%%% 	F='/usr/local/lib/ppl/ppl_sicstus.pl',
%%%         (file_exists(F) ->
%%% 	    % hence main has already compiled F (...),
%%% 	    % we just reinitialize it
%%% 	    user:ppl_initialize,
%%% 	    retract(current_cti_flag(poly_lib,_)),!,
%%% 	    assert(current_cti_flag(poly_lib,poly_ppl))
%%% 	;
%%% 	    write('Please install PPL'),
%%% 	    fail).

%%% switch_to_clpq(poly_clpq).
%%% switch_to_clpq(poly_ppl) :-
%%% 	retract(current_cti_flag(poly_lib,_)),!,
%%% 	assert(current_cti_flag(poly_lib,poly_clpq)).

