1 // Created on: 1994-08-01
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TestTopOpeTools_Trace.hxx>
19 TestTopOpeTools_Trace::TestTopOpeTools_Trace
20 (const Standard_Integer nbmaxentry,
21 const TCollection_AsciiString& genre) :
23 myfirstentry(1),mynbmaxentry(nbmaxentry),mynbentries(0),
24 myflag(myfirstentry,mynbmaxentry),
25 myftyp(myfirstentry,mynbmaxentry),
26 myverbose(Standard_False),
27 myfverbose(myfirstentry,mynbmaxentry)
30 TestTopOpeTools_Trace::TestTopOpeTools_Trace
31 (const Standard_Integer nbmaxentry) :
33 myfirstentry(1),mynbmaxentry(nbmaxentry),mynbentries(0),
34 myflag(myfirstentry,mynbmaxentry),
35 myftyp(myfirstentry,mynbmaxentry),
36 myverbose(Standard_False),
37 myfverbose(myfirstentry,mynbmaxentry)
40 Standard_Integer TestTopOpeTools_Trace::Add
41 (const t_flag flag,tf_value func)
42 { return Add(flag,(tf_value)func,te_value); }
44 Standard_Integer TestTopOpeTools_Trace::SetVerbose
45 (const Standard_Boolean b)
46 { myverbose = b; return 0;}
48 Standard_Integer TestTopOpeTools_Trace::SetVerbose
49 (const t_flag flag,const Standard_Boolean b)
51 Standard_Integer index = 0;
52 if ( !Exist(flag,index) ) return 1;
53 if (b) cout<<"set "<<mygenre<<" "<<flag<<" verbose"<<endl;
54 else cout<<"set "<<mygenre<<" "<<flag<<" not verbose"<<endl;
55 myfverbose.SetValue(index,b);
59 Standard_Integer TestTopOpeTools_Trace::Set
60 (const Standard_Integer mute,const t_flag flag,const t_value value)
62 Standard_Integer index = 0;
63 if ( !Exist(flag,index) ) return 1;
65 if (value) cout<<"activation de "<<mygenre<<" "<<flag<<endl;
66 else cout<<"desactivation de "<<mygenre<<" "<<flag<<endl;
68 (*((tf_value)Getfunc(index)))(value);
72 Standard_Integer TestTopOpeTools_Trace::Add
73 (const t_flag flag,tf_intarg func)
74 { return Add(flag,(tf_value)func,te_intarg); }
76 Standard_Integer TestTopOpeTools_Trace::Add
77 (const t_flag flag,tf_int_intarg func)
78 { return Add(flag,(tf_value)func,te_int_intarg); }
80 Standard_Integer TestTopOpeTools_Trace::Set
81 (const Standard_Integer mute,const t_flag flag, const t_value value,
82 Standard_Integer n, const char** a)
84 Standard_Integer index = 0;
85 if ( !Exist(flag,index) ) return 1;
86 if ( Getftyp(index) == te_intarg ) {
87 (*((tf_intarg)Getfunc(index)))(value,n,a);
89 cout<<mygenre<<" "<<flag<<" active avec :";
91 for(Standard_Integer i=0;i<n;i++) cout<<" "<<a[i];
95 else if ( Getftyp(index) == te_int_intarg ) {
96 Standard_Integer err = (*((tf_int_intarg)Getfunc(index)))(value,n,a);
98 cout<<"ERREUR activation de "<<mygenre<<" "<<flag<<" "<<value;
99 for(Standard_Integer i=0;i<n;i++) cout<<" "<<a[i];cout<<endl;
103 cout<<mygenre<<" "<<flag<<" active avec :";
105 for(Standard_Integer i=0;i<n;i++) cout<<" "<<a[i];
110 else if ( Getftyp(index) == te_value ) {
111 return Set(mute,flag,value);
114 cout<<"TestTopOpeTools_Trace::Set : unknown function type"<<endl;
120 void TestTopOpeTools_Trace::Dump()
122 for (Standard_Integer i=myfirstentry; i<=mynbentries; i++) {
123 if (i==myfirstentry) cout<<"Defined "<<mygenre<<"s :";
124 cout<<" "<<Getflag(i);
125 if (i==mynbentries) cout<<endl;
129 void TestTopOpeTools_Trace::Reset(const t_value value)
131 for (Standard_Integer i=myfirstentry;i<=mynbentries;i++)
132 if (Getftyp(i)==te_value)
133 (*((tf_value)Getfunc(i)))(value);
134 else if (Getftyp(i)==te_intarg)
135 (*((tf_intarg)Getfunc(i)))(value,0,NULL);
136 else if (Getftyp(i)==te_int_intarg)
137 (*((tf_int_intarg)Getfunc(i)))(value,0,NULL);
142 Standard_Boolean TestTopOpeTools_Trace::Exist
143 (const t_flag flag, Standard_Integer& index)
145 for (Standard_Integer i=myfirstentry; i<=mynbentries; i++)
146 if (myflag.Value(i).IsEqual(flag)) { index = i; return Standard_True; }
147 return Standard_False;
150 Standard_Boolean TestTopOpeTools_Trace::Exist
151 (const tf_value func, Standard_Integer& index)
153 for (Standard_Integer i=myfirstentry; i<=mynbentries; i++)
154 if (myfunc.Value(i) == func) { index = i; return Standard_True; }
155 return Standard_False;
158 const t_flag TestTopOpeTools_Trace::Getflag(const Standard_Integer index)
159 { return (t_flag)myflag.Value(index); }
161 tf_value TestTopOpeTools_Trace::Getfunc(const Standard_Integer index)
162 { return myfunc.Value(index); }
164 te_ftyp TestTopOpeTools_Trace::Getftyp(const Standard_Integer index)
167 Standard_Integer intenum = myftyp.Value(index);
168 return (te_ftyp) intenum ;
169 // return (te_ftyp) myftyp.Value(index);
172 Standard_Integer TestTopOpeTools_Trace::Add
173 (const t_flag flag, const tf_value func, const te_ftyp ftyp)
175 Standard_Integer index;
176 if ( Exist(flag,index) || ( mynbentries >= mynbmaxentry) ) return 1;
178 myflag.SetValue(mynbentries,flag);
179 myfunc.SetValue(mynbentries,func);
180 myftyp.SetValue(mynbentries,(Standard_Integer)ftyp);
181 myfverbose.SetValue(mynbentries,Standard_False);