**** Merged from MCS ****
[mono-project.git] / mcs / class / System / System.Diagnostics / PerformanceCounter.cs
blobcda6f61a873e01b058097458381f06a7eff80fe1
1 //
2 // System.Diagnostics.PerformanceCounter.cs
3 //
4 // Authors:
5 // Jonathan Pryor (jonpryor@vt.edu)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 //
8 // (C) 2002
9 // (C) 2003 Andreas Nahr
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System;
34 using System.ComponentModel;
35 using System.ComponentModel.Design;
36 using System.Diagnostics;
38 namespace System.Diagnostics {
40 // must be safe for multithreaded operations
41 [Designer ("Microsoft.VisualStudio.Install.PerformanceCounterDesigner, Microsoft.VisualStudio, " + Consts.AssemblyMicrosoft_VisualStudio, typeof (IDesigner))]
42 [InstallerType (typeof (PerformanceCounterInstaller))]
43 public sealed class PerformanceCounter : Component, ISupportInitialize
46 private string categoryName;
47 private string counterName;
48 private string instanceName;
49 private string machineName;
50 private bool readOnly;
52 public static int DefaultFileMappingSize = 524288;
54 // set catname, countname, instname to "", machname to "."
55 public PerformanceCounter ()
57 categoryName = counterName = instanceName = "";
58 machineName = ".";
61 // throws: InvalidOperationException (if catName or countName
62 // is ""); ArgumentNullException if either is null
63 // sets instName to "", machname to "."
64 public PerformanceCounter (String categoryName,
65 string counterName)
66 : this (categoryName, counterName, false)
70 public PerformanceCounter (string categoryName,
71 string counterName,
72 bool readOnly)
73 : this (categoryName, counterName, "", readOnly)
77 public PerformanceCounter (string categoryName,
78 string counterName,
79 string instanceName)
80 : this (categoryName, counterName, instanceName, false)
84 public PerformanceCounter (string categoryName,
85 string counterName,
86 string instanceName,
87 bool readOnly)
90 CategoryName = categoryName;
91 CounterName = counterName;
93 if (categoryName == "" || counterName == "")
94 throw new InvalidOperationException ();
96 InstanceName = instanceName;
97 this.instanceName = instanceName;
98 this.machineName = ".";
99 this.readOnly = readOnly;
102 public PerformanceCounter (string categoryName,
103 string counterName,
104 string instanceName,
105 string machineName)
106 : this (categoryName, counterName, instanceName, false)
108 this.machineName = machineName;
111 // may throw ArgumentNullException
112 [DefaultValue (""), ReadOnly (true), RecommendedAsConfigurable (true)]
113 [TypeConverter ("System.Diagnostics.Design.CategoryValueConverter, " + Consts.AssemblySystem_Design)]
114 [SRDescription ("The category name for this performance counter.")]
115 public string CategoryName {
116 get {return categoryName;}
117 set {
118 if (value == null)
119 throw new ArgumentNullException ("categoryName");
120 categoryName = value;
124 // may throw InvalidOperationException
125 [MonoTODO]
126 [ReadOnly (true), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
127 [MonitoringDescription ("A description describing the counter.")]
128 public string CounterHelp {
129 get {return "";}
132 // may throw ArgumentNullException
133 [DefaultValue (""), ReadOnly (true), RecommendedAsConfigurable (true)]
134 [TypeConverter ("System.Diagnostics.Design.CounterNameConverter, " + Consts.AssemblySystem_Design)]
135 [SRDescription ("The name of this performance counter.")]
136 public string CounterName
138 get {return counterName;}
139 set {
140 if (value == null)
141 throw new ArgumentNullException ("counterName");
142 counterName = value;
146 // may throw InvalidOperationException
147 [MonoTODO]
148 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
149 [MonitoringDescription ("The type of the counter.")]
150 public PerformanceCounterType CounterType {
151 get {return 0;}
154 [DefaultValue (""), ReadOnly (true), RecommendedAsConfigurable (true)]
155 [TypeConverter ("System.Diagnostics.Design.InstanceNameConverter, " + Consts.AssemblySystem_Design)]
156 [SRDescription ("The instance name for this performance counter.")]
157 public string InstanceName
159 get {return instanceName;}
160 set {instanceName = value;}
163 // may throw ArgumentException if machine name format is wrong
164 [MonoTODO("What's the machine name format?")]
165 [DefaultValue ("."), Browsable (false), RecommendedAsConfigurable (true)]
166 [SRDescription ("The machine where this performance counter resides.")]
167 public string MachineName {
168 get {return machineName;}
169 set {machineName = value;}
172 // may throw InvalidOperationException, Win32Exception
173 [MonoTODO]
174 [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
175 [MonitoringDescription ("The raw value of the counter.")]
176 public long RawValue {
177 get {return 0;}
178 set {
179 throw new NotImplementedException ();
183 [Browsable (false), DefaultValue (true)]
184 [MonitoringDescription ("The accessability level of the counter.")]
185 public bool ReadOnly {
186 get {return readOnly;}
187 set {readOnly = value;}
190 [MonoTODO]
191 public void BeginInit ()
193 throw new NotImplementedException ();
196 [MonoTODO]
197 public void Close ()
199 throw new NotImplementedException ();
202 [MonoTODO]
203 public static void CloseSharedResources ()
205 throw new NotImplementedException ();
208 // may throw InvalidOperationException, Win32Exception
209 [MonoTODO]
210 public long Decrement ()
212 throw new NotImplementedException ();
215 [MonoTODO]
216 protected override void Dispose (bool disposing)
218 throw new NotImplementedException ();
221 [MonoTODO]
222 public void EndInit ()
224 throw new NotImplementedException ();
227 // may throw InvalidOperationException, Win32Exception
228 [MonoTODO]
229 public long Increment ()
231 throw new NotImplementedException ();
234 // may throw InvalidOperationException, Win32Exception
235 [MonoTODO]
236 public long IncrementBy (long value)
238 throw new NotImplementedException ();
241 // may throw InvalidOperationException, Win32Exception
242 [MonoTODO]
243 public CounterSample NextSample ()
245 throw new NotImplementedException ();
248 // may throw InvalidOperationException, Win32Exception
249 [MonoTODO]
250 public float NextValue ()
252 throw new NotImplementedException ();
255 // may throw InvalidOperationException, Win32Exception
256 [MonoTODO]
257 public void RemoveInstance ()
259 throw new NotImplementedException ();