Switches (Boolean & Trace) should be working now. Behavior of user-provided
[mono.git] / mcs / class / System / System.Diagnostics / PerformanceCounter.cs
1 //
2 // System.Diagnostics.PerformanceCounter.cs
3 //
4 // Authors:
5 //   Jonathan Pryor (jonpryor@vt.edu)
6 //
7 // (C) 2002
8 //
9
10 using System;
11 using System.ComponentModel;
12 using System.Diagnostics;
13
14 namespace System.Diagnostics {
15
16         // must be safe for multithreaded operations
17         public class PerformanceCounter : Component, ISupportInitialize {
18
19                 private string categoryName;
20                 private string counterName;
21                 private string instanceName;
22                 private string machineName;
23                 private bool readOnly;
24
25                 [MonoTODO("Find the actual value")]
26                 public static int DefaultFileMappingSize = 0x80000;
27
28                 // set catname, countname, instname to "", machname to "."
29                 public PerformanceCounter ()
30                 {
31                         categoryName = counterName = instanceName = "";
32                         machineName = ".";
33                 }
34
35                 // throws: InvalidOperationException (if catName or countName
36                 // is ""); ArgumentNullException if either is null
37                 // sets instName to "", machname to "."
38                 public PerformanceCounter (String categoryName, 
39                         string counterName)
40                         : this (categoryName, counterName, false)
41                 {
42                 }
43
44                 public PerformanceCounter (string categoryName, 
45                         string counterName,
46                         bool readOnly)
47                         : this (categoryName, counterName, "", readOnly)
48                 {
49                 }
50
51                 public PerformanceCounter (string categoryName,
52                         string counterName,
53                         string instanceName)
54                         : this (categoryName, counterName, instanceName, false)
55                 {
56                 }
57
58                 public PerformanceCounter (string categoryName,
59                         string counterName,
60                         string instanceName,
61                         bool readOnly)
62                 {
63
64                         CategoryName = categoryName;
65                         CounterName = counterName;
66
67                         if (categoryName == "" || counterName == "")
68                                 throw new InvalidOperationException ();
69
70                         InstanceName = instanceName;
71                         this.instanceName = instanceName;
72                         this.machineName = ".";
73                         this.readOnly = readOnly;
74                 }
75
76                 public PerformanceCounter (string categoryName,
77                         string counterName,
78                         string instanceName,
79                         string machineName)
80                         : this (categoryName, counterName, instanceName, false)
81                 {
82                         this.machineName = machineName;
83                 }
84
85                 // may throw ArgumentNullException
86                 public string CategoryName {
87                         get {return categoryName;}
88                         set {
89                                 if (value == null)
90                                         throw new ArgumentNullException ("categoryName");
91                                 categoryName = value;
92                         }
93                 }
94
95 //              // may throw InvalidOperationException
96 //              [MonoTODO]
97 //              public string CounterHelp {
98 //                      get {return "";}
99 //              }
100 //
101                 // may throw ArgumentNullException
102                 public string CounterName {
103                         get {return counterName;}
104                         set {
105                                 if (value == null)
106                                         throw new ArgumentNullException ("counterName");
107                                 counterName = value;
108                         }
109                 }
110
111 //              // may throw InvalidOperationException
112 //              [MonoTODO]
113 //              public PerformanceCounterType CounterType {
114 //                      get {return 0;}
115 //              }
116 //
117                 public string InstanceName {
118                         get {return instanceName;}
119                         set {instanceName = value;}
120                 }
121
122 //              // may throw ArgumentException if machine name format is wrong
123 //              [MonoTODO("What's the machine name format?")]
124 //              public string MachineName {
125 //                      get {return machineName;}
126 //                      set {machineName = value;}
127 //              }
128 //
129 //              // may throw InvalidOperationException, Win32Exception
130 //              [MonoTODO]
131 //              public long RawValue {
132 //                      get {return 0;}
133 //                      set {
134 //                              throw new NotImplementedException ();
135 //                      }
136 //              }
137 //
138 //              public bool ReadOnly {
139 //                      get {return readOnly;}
140 //                      set {readOnly = value;}
141 //              }
142 //
143                 [MonoTODO]
144                 public void BeginInit ()
145                 {
146                         throw new NotImplementedException ();
147                 }
148
149 //              [MonoTODO]
150 //              public void Close ()
151 //              {
152 //                      throw new NotImplementedException ();
153 //              }
154 //
155 //              [MonoTODO]
156 //              public static void CloseSharedResources ()
157 //              {
158 //                      throw new NotImplementedException ();
159 //              }
160 //
161 //              // may throw InvalidOperationException, Win32Exception
162 //              [MonoTODO]
163 //              public long Decrement ()
164 //              {
165 //                      throw new NotImplementedException ();
166 //              }
167 //
168 //              [MonoTODO]
169 //              protected override void Dispose (bool disposing)
170 //              {
171 //                      throw new NotImplementedException ();
172 //              }
173 //
174                 [MonoTODO]
175                 public void EndInit ()
176                 {
177                         throw new NotImplementedException ();
178                 }
179
180 //              // may throw InvalidOperationException, Win32Exception
181 //              [MonoTODO]
182 //              public long Increment ()
183 //              {
184 //                      throw new NotImplementedException ();
185 //              }
186 //
187 //              // may throw InvalidOperationException, Win32Exception
188 //              [MonoTODO]
189 //              public long IncrementBy (long value)
190 //              {
191 //                      throw new NotImplementedException ();
192 //              }
193 //
194 //              // may throw InvalidOperationException, Win32Exception
195 //              [MonoTODO]
196 //              public CounterSample NextSample ()
197 //              {
198 //                      throw new NotImplementedException ();
199 //              }
200 //
201 //              // may throw InvalidOperationException, Win32Exception
202 //              [MonoTODO]
203 //              public float NextValue ()
204 //              {
205 //                      throw new NotImplementedException ();
206 //              }
207 //
208 //              // may throw InvalidOperationException, Win32Exception
209 //              [MonoTODO]
210 //              public void RemoveInstance ()
211 //              {
212 //                      throw new NotImplementedException ();
213 //              }
214         }
215 }
216