/[marvin]/marvin/src/libnn/misc/env.ml
ViewVC logotype

Diff of /marvin/src/libnn/misc/env.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by srv89, Tue Sep 9 12:48:47 2003 UTC revision 1.5 by srv89, Tue Sep 9 15:58:23 2003 UTC
# Line 46  Line 46 
46    instance of the environment class.    instance of the environment class.
47    The aim is to provide information about the learning environment to the    The aim is to provide information about the learning environment to the
48    various objects involved in LibNN.    various objects involved in LibNN.
49    
50      Verbosity levels (possible values for the _verbosity attribute):
51      0 -> Nothing at all is displayed.
52      1 -> Only errors are displayed.
53      2 -> Errors and warnings are displayed.
54      3 -> Errors + warnings + LibNN verbosity 1 (only basic informations
55      displayed).
56      4 -> Errors + warnings + LibNN verbosity 2 (when a method listed in the API
57      is called, one message is displayed).
58      5 -> Errors + warnings + LibNN verbosity 3 (when a method listed in the API
59      is called, more than one message will be displayed).
60      6 -> Errors + warnings + LibNN verbosity 4 (debugging informations are
61      displayed).
62    
63      What verbosity level shoul I use?
64      While writing/debugging a software that uses LibNN, 4 is fine.
65      For an official release of a software that uses LibNN, 3 is fine.
66    
67    //FIXME explain how to use the getEnv method in other classes.    //FIXME explain how to use the getEnv method in other classes.
68    @see <http://theory.lcs.mit.edu/~dnj/6898/projects/vicente-wagner.pdf> A PDF document about Design Patterns and OCaml.    @see <http://theory.lcs.mit.edu/~dnj/6898/projects/vicente-wagner.pdf> A PDF
69      document about Design Patterns and OCaml.
70  *)  *)
71    
72  class type environmentType =  class type environmentType =
# Line 96  object Line 115  object
115      @param module_name      @param module_name
116      The name of the module who is speaking (displayed in the output).      The name of the module who is speaking (displayed in the output).
117      @param msg The message to be displayed.      @param msg The message to be displayed.
118        @param min_verbosity_level If _verbosity >= this parameter, the message
119        is displayed.
120    *)    *)
121    method out : string -> string -> unit    method out : string -> string -> int -> unit
122    
123      (**      (**
124        A set*.        A set*.
# Line 116  object Line 137  object
137      @param module_name      @param module_name
138      The name of the module who is speaking (displayed in the output).      The name of the module who is speaking (displayed in the output).
139      @param msg The message to be displayed.      @param msg The message to be displayed.
140        @param min_verbosity_level If _verbosity >= this parameter, the message
141        is displayed.
142    *)    *)
143    method err : string -> string -> unit    method err : string -> string -> int -> unit
144    
145    (**
146      Converts an otuput channel to a string (useful for dumping the current
147      output channel as xml...).
148      @param channel The channel to convert in string.
149    *)
150      method string_of_channel : out_channel -> string
151    
152  end  end
153    
# Line 125  end Line 155  end
155    The environment itself.    The environment itself.
156  *)  *)
157  class environment : environmentType =  class environment : environmentType =
158  object  object(this)
159    
160    (**    (**
161      The verbosity level.      The verbosity level.
# Line 147  object Line 177  object
177      Sets the current output channel.      Sets the current output channel.
178    *)    *)
179    method setOutChannel newval =    method setOutChannel newval =
180      _outChannel <- newval      _outChannel <- newval;
181        this#out "environment" ("set `" ^ (this#string_of_channel _outChannel)
182                     ^ "\' as standard output.") 4
183                
184    (**    (**
185      Gets the current output channel.      Gets the current output channel.
# Line 160  object Line 192  object
192      @param module_name      @param module_name
193      The name of the module who is speaking (displayed in the output).      The name of the module who is speaking (displayed in the output).
194      @param msg The message to be displayed.      @param msg The message to be displayed.
195        @param min_verbosity_level If _verbosity >= this parameter, the message
196        is displayed.
197    *)    *)
198    method out module_name msg =    method out module_name msg min_verbosity_level =
199      let str =      if ( _verbosity >= min_verbosity_level ) then
200        ("[LibNN] (" ^ module_name ^ "): " ^ msg) in        (let str =
201        Printf.fprintf _outChannel " %s\n" str           ("[LibNN] (" ^ module_name ^ "): " ^ msg) in
202             Printf.fprintf _outChannel " %s\n" str)
203    
204    (**    (**
205      The channel on which LibNN is supposed to display errors (like stderr on      The channel on which LibNN is supposed to display errors (like stderr on
# Line 176  object Line 211  object
211      Sets the current error channel.      Sets the current error channel.
212    *)    *)
213    method setErrChannel newval =    method setErrChannel newval =
214      _errChannel <- newval      _errChannel <- newval;
215        this#out "environment" ("set `" ^ (this#string_of_channel _outChannel)
216                  ^ "\' as error output.") 4
217                
218    (**    (**
219      Gets the current error channel.      Gets the current error channel.
# Line 189  object Line 226  object
226      @param module_name      @param module_name
227      The name of the module who is speaking (displayed in the output).      The name of the module who is speaking (displayed in the output).
228      @param msg The message to be displayed.      @param msg The message to be displayed.
229        @param min_verbosity_level If _verbosity >= this parameter, the message
230        is displayed.
231    *)    *)
232    method err module_name msg =    method err module_name msg min_verbosity_level =
233      let str =      if ( _verbosity >= min_verbosity_level ) then
234        ("[LibNN] (" ^ module_name ^ "): ERROR: " ^ msg) in        (let str =
235        Printf.fprintf _errChannel " %s\n" str           ("[LibNN] (" ^ module_name ^ "): ERROR: " ^ msg) in
236             Printf.fprintf _errChannel " %s\n" str)
237                    
238    (**    (**
239      Sets the current verbosity level.      Sets the current verbosity level.
240        This method is not verbose because otherwise it would be impossible to
241        <b>totally</b> mute LibNN.
242    *)    *)
243    method setVerbosity newval =    method setVerbosity newval =
244      _verbosity <- newval      _verbosity <- newval
# Line 219  object Line 261  object
261    method getRandLimit =    method getRandLimit =
262      _randLimit      _randLimit
263    
264      (**
265        Converts an otuput channel to a string (useful for dumping the current
266        output channel as xml...).
267        @param channel The channel to convert in string.
268      *)
269      method string_of_channel channel =
270        match channel with
271            stdout when stdout = Pervasives.stdout -> "stdout"
272          | stderr when stderr = Pervasives.stderr -> "stderr"
273          | _ -> "unknown"
274    
275  end  end
276    
277  let env : environmentType option ref = ref None  let env : environmentType option ref = ref None

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26