function cvinit( command )
%CVINIT  Initializes Coverage module.
%  This is the callback function executed upon the initialization
%  of CV (MEX file). It is also used to load and save defaults.

%   Bill Aldrich
%   Copyright 1990-2004 The MathWorks, Inc.
%   $Revision: 1.13.2.6 $  $Date: 2004/08/10 02:16:49 $



if nargin==0
    cv('lock');
    cvinit('load defaults');
    cvinit('formatters');

	% LOAD THE SUPPORT FILES
	% Enable the dicumentation mechanism
	%caption_prep;
	return;
end

switch command
case 'factory',
	relax_flags;
case 'load defaults',
	restore_flags;
case 'formatters',
	load_formatters;
case 'save_defaults',
	restore_flags;
case 'save defaults',
	restore_flags;
end


function relax_flags
	cv('flag'...
		,'modelcov:all','write'...
		,'slsfobj:all','write'...
		,'decision:all','write'...
		,'relation:all','write'...
		,'condition:all','write'...
		,'caption:all','write'...
	);

function restore_flags
	cv('flag'...
		,'modelcov:all',                    'save/show'...
        ,'modelcov.isa',                    'nosave'... 
        ,'modelcov.handle',                 'nosave'... 
        ,'modelcov.currentDisplay:all',     'nosave'... 
        ,'modelcov.slChecksum',             'nosave'...
        ,'modelcov.sfChecksum',             'nosave'...
        ,'modelcov.deleteTrees',             'nosave'...
        ,'modelcov.deleteRoots',             'nosave'...
        ,'modelcov.staleRoots',             'nosave'...
        ,'modelcov.activeRoot',             'nosave'...
        ,'modelcov.activeTest',             'nosave'...
        ,'modelcov.explorer:all',           'nosave'...
	);

	cv('flag'...
		,'slsfobj:all',                     'save/show'...
		,'slsfobj.isa',                     'nosave/show'...
		,'slsfobj.handle',                  'nosave/show'...
		,'slsfobj.cvChecksum',              'nosave/show'...
     );

	cv('flag'...
		,'decision:all',                    'save/show'...
		,'decision.isa',                    'nosave/show'...
		,'decision.descriptor',             'save/show'...
		,'decision.outMsgs',         		'save/show'...
	);

	cv('flag'...
		,'relation:all',                    'save/show'...
		,'relation.isa',                    'nosave'...
		,'relation.descriptor',            	'save/show'...
	);

	cv('flag'...
		,'root:all',                         'save/show'...
		,'root.isa',                         'nosave'...
		,'root.runningTotal',                'save/show'...
		,'root.topSlHandle',                 'nosave'...
	);

	cv('flag'...
		,'condition:all',                    'save/show'...
		,'condition.isa',                    'nosave'...
		,'condition.descriptor',             'save/show'...
	);

	cv('flag'...
		,'codeblock:all',                    'save/show'...
		,'codeblock.isa',                    'nosave'...
		,'codeblock.lineStartInd',           'nosave'...
		,'codeblock.styleIdx',               'nosave'...
		,'codeblock.hyperlink',              'nosave'...
	);

	cv('flag'...
		,'message:all',                    'save/show'...
		,'message.isa',                    'nosave'...
		,'message.formatter',              'nosave'...
	);

	cv('flag'...
		,'testdata:all',                    'save/show'...
		,'testdata.data:all',               'nosave/show'...
		,'testdata.data.decision',          'save/show'...
		,'testdata.data.condition',         'save/show'...
		,'testdata.data.relation',          'save/show'...
		,'testdata.data.mcdc',              'save/show'...
		,'testdata.data.tableExec',         'save/show'...
		,'testdata.data.sigrange',          'save/show'...
	);

	cv('flag'...
		,'sigranger:all',                     'save/show'...
		,'sigranger.isa',                     'nosave/show'...
		,'sigranger.handle',                  'nosave/show'...
		,'sigranger.markStatus',              'nosave/show'...
	);



function load_formatters,
    make_formatters;
    frmts = cv('get','all','formatter.id');
    for h = frmts(:)'
        parse_formatter_strings(h);
    end
