/[marvin]/marvin/src/libnn/Env.ml
ViewVC logotype

Diff of /marvin/src/libnn/Env.ml

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

revision 1.1 by matthieu, Mon Jul 7 22:52:54 2003 UTC revision 1.2 by matthieu, Tue Jul 8 15:45:08 2003 UTC
# Line 32  E-mail : olivier@marvinproject.org Line 32  E-mail : olivier@marvinproject.org
32    @author Matthieu Lagacherie    @author Matthieu Lagacherie
33    @author Olivier Ricordeau    @author Olivier Ricordeau
34        
35      This class use the design pattern Singleton in order
36      to provide only one instance of the environment class
37  *)  *)
38    
39  class environment =  class type environment =
40    object
41      method toChannel : string -> unit
42      method setVerbosity : int-> unit
43    end
44    
45    class environmentImpl: singleton =
46  object  object
47    val mutable _verbosity = 0    val mutable _verbosity = 0
48    val mutable _channel = stderr    val mutable _channel = stderr
49    method toChannel str = Printf.fprintf _channel "%s\n" str    method toChannel str = Printf.fprintf _channel "%s\n" str
50    method setVerbosity newval = _verbosity <- newval    method setVerbosity newval = _verbosity <- newval
51  end;;  end
52    
53    let env : environment option ref = ref None
54    
55    let getInstance () : environment =
56         match !env with
57             None ->
58               let result = new environmentImpl
59               in
60                 env := Some result;
61                 result
62           | Some result -> result
63    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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