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 myfunc(myfirstentry,mynbmaxentry),
26 myftyp(myfirstentry,mynbmaxentry),
27 myverbose(Standard_False),
28 myfverbose(myfirstentry,mynbmaxentry)
31 TestTopOpeTools_Trace::TestTopOpeTools_Trace
32 (const Standard_Integer nbmaxentry) :
34 myfirstentry(1),mynbmaxentry(nbmaxentry),mynbentries(0),
35 myflag(myfirstentry,mynbmaxentry),
36 myfunc(myfirstentry,mynbmaxentry),
37 myftyp(myfirstentry,mynbmaxentry),
38 myverbose(Standard_False),
39 myfverbose(myfirstentry,mynbmaxentry)
42 Standard_Integer TestTopOpeTools_Trace::Add
43 (const t_flag flag,tf_value func)
44 { return Add(flag,(tf_value)func,te_value); }
46 Standard_Integer TestTopOpeTools_Trace::SetVerbose
47 (const Standard_Boolean b)
48 { myverbose = b; return 0;}
50 Standard_Integer TestTopOpeTools_Trace::SetVerbose
51 (const t_flag flag,const Standard_Boolean b)
53 Standard_Integer index = 0;
54 if ( !Exist(flag,index) ) return 1;
55 if (b) cout<<"set "<<mygenre<<" "<<flag<<" verbose"<<endl;
56 else cout<<"set "<<mygenre<<" "<<flag<<" not verbose"<<endl;
57 myfverbose.SetValue(index,b);
61 Standard_Integer TestTopOpeTools_Trace::Set
62 (const Standard_Integer mute,const t_flag flag,const t_value value)
64 Standard_Integer index = 0;
65 if ( !Exist(flag,index) ) return 1;
67 if (value) cout<<"activation de "<<mygenre<<" "<<flag<<endl;
68 else cout<<"desactivation de "<<mygenre<<" "<<flag<<endl;
70 (*((tf_value)Getfunc(index)))(value);
74 Standard_Integer TestTopOpeTools_Trace::Add
75 (const t_flag flag,tf_intarg func)
76 { return Add(flag,(tf_value)func,te_intarg); }
78 Standard_Integer TestTopOpeTools_Trace::Add
79 (const t_flag flag,tf_int_intarg func)
80 { return Add(flag,(tf_value)func,te_int_intarg); }
82 Standard_Integer TestTopOpeTools_Trace::Set
83 (const Standard_Integer mute,const t_flag flag, const t_value value,
84 Standard_Integer n, const char** a)
86 Standard_Integer index = 0;
87 if ( !Exist(flag,index) ) return 1;
88 if ( Getftyp(index) == te_intarg ) {
89 (*((tf_intarg)Getfunc(index)))(value,n,a);
91 cout<<mygenre<<" "<<flag<<" active avec :";
93 for(Standard_Integer i=0;i<n;i++) cout<<" "<<a[i];
97 else if ( Getftyp(index) == te_int_intarg ) {
98 Standard_Integer err = (*((tf_int_intarg)Getfunc(index)))(value,n,a);
100 cout<<"ERREUR activation de "<<mygenre<<" "<<flag<<" "<<value;
101 for(Standard_Integer i=0;i<n;i++) cout<<" "<<a[i];cout<<endl;
105 cout<<mygenre<<" "<<flag<<" active avec :";
107 for(Standard_Integer i=0;i<n;i++) cout<<" "<<a[i];
112 else if ( Getftyp(index) == te_value ) {
113 return Set(mute,flag,value);
116 cout<<"TestTopOpeTools_Trace::Set : unknown function type"<<endl;
122 void TestTopOpeTools_Trace::Dump()
124 for (Standard_Integer i=myfirstentry; i<=mynbentries; i++) {
125 if (i==myfirstentry) cout<<"Defined "<<mygenre<<"s :";
126 cout<<" "<<Getflag(i);
127 if (i==mynbentries) cout<<endl;
131 void TestTopOpeTools_Trace::Reset(const t_value value)
133 for (Standard_Integer i=myfirstentry;i<=mynbentries;i++)
134 if (Getftyp(i)==te_value)
135 (*((tf_value)Getfunc(i)))(value);
136 else if (Getftyp(i)==te_intarg)
137 (*((tf_intarg)Getfunc(i)))(value,0,NULL);
138 else if (Getftyp(i)==te_int_intarg)
139 (*((tf_int_intarg)Getfunc(i)))(value,0,NULL);
144 Standard_Boolean TestTopOpeTools_Trace::Exist
145 (const t_flag flag, Standard_Integer& index)
147 for (Standard_Integer i=myfirstentry; i<=mynbentries; i++)
148 if (myflag.Value(i).IsEqual(flag)) { index = i; return Standard_True; }
149 return Standard_False;
152 Standard_Boolean TestTopOpeTools_Trace::Exist
153 (const tf_value func, Standard_Integer& index)
155 for (Standard_Integer i=myfirstentry; i<=mynbentries; i++)
156 if (myfunc.Value(i) == ((long)func)) { index = i; return Standard_True; }
157 return Standard_False;
160 const t_flag TestTopOpeTools_Trace::Getflag(const Standard_Integer index)
161 { return (t_flag)myflag.Value(index); }
163 const tf_value TestTopOpeTools_Trace::Getfunc(const Standard_Integer index)
164 { return (tf_value)myfunc.Value(index); }
166 const te_ftyp TestTopOpeTools_Trace::Getftyp(const Standard_Integer index)
169 Standard_Integer intenum = myftyp.Value(index);
170 return (te_ftyp) intenum ;
171 // return (te_ftyp) myftyp.Value(index);
174 Standard_Integer TestTopOpeTools_Trace::Add
175 (const t_flag flag, const tf_value func, const te_ftyp ftyp)
177 Standard_Integer index;
178 if ( Exist(flag,index) || ( mynbentries >= mynbmaxentry) ) return 1;
180 myflag.SetValue(mynbentries,flag);
181 myfunc.SetValue(mynbentries,(long)func);
182 myftyp.SetValue(mynbentries,(Standard_Integer)ftyp);
183 myfverbose.SetValue(mynbentries,Standard_False);