Qpid .NET Messaging API  0.24
 All Classes Namespaces Files Functions Variables Typedefs
Duration.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 
20 #pragma once
21 
22 #include <windows.h>
23 #include <msclr\lock.h>
24 #include <oletx2xa.h>
25 #include <string>
26 #include <limits>
27 
28 namespace Org {
29 namespace Apache {
30 namespace Qpid {
31 namespace Messaging {
32 
37 
38  public ref class Duration sealed
39  {
40  private:
41  System::UInt64 milliseconds;
42 
43  public:
44 
45  Duration(const Duration % rhs) :
46  milliseconds(rhs.milliseconds) {}
47 
48  explicit Duration(System::UInt64 mS) :
49  milliseconds(mS) {}
50 
51  Duration() :
52  milliseconds(System::UInt64::MaxValue) {}
53 
54  property System::UInt64 Milliseconds
55  {
56  System::UInt64 get () { return milliseconds; }
57  }
58 
59  static Duration ^ operator * (Duration ^ dur, const System::UInt64 multiplier)
60  {
61  Duration ^ result = gcnew Duration(dur->Milliseconds * multiplier);
62  return result;
63  }
64 
65  static Duration ^ operator * (const System::UInt64 multiplier, Duration ^ dur)
66  {
67  Duration ^ result = gcnew Duration(multiplier * dur->Milliseconds);
68  return result;
69  }
70 
71  static Duration ^ Multiply (Duration ^ dur, const System::UInt64 multiplier)
72  {
73  Duration ^ result = gcnew Duration(dur->Milliseconds * multiplier);
74  return result;
75  }
76 
77  static Duration ^ Multiply (const System::UInt64 multiplier, Duration ^ dur)
78  {
79  Duration ^ result = gcnew Duration(multiplier * dur->Milliseconds);
80  return result;
81  }
82 
83  static bool operator == (Duration ^ a, Duration ^ b)
84  {
85  return a->Milliseconds == b->Milliseconds;
86  }
87 
88  static bool operator != (Duration ^ a, Duration ^ b)
89  {
90  return a->Milliseconds != b->Milliseconds;
91  }
92  };
93 
94  public ref class DurationConstants sealed
95  {
96  private:
97  DurationConstants::DurationConstants() {}
98 
99  public:
100  static Duration ^ FORVER;
101  static Duration ^ IMMEDIATE;
102  static Duration ^ SECOND;
103  static Duration ^ MINUTE;
104 
105  static DurationConstants()
106  {
107  FORVER = gcnew Duration();
108  IMMEDIATE = gcnew Duration(0);
109  SECOND = gcnew Duration(1000);
110  MINUTE = gcnew Duration(60000);
111  }
112  };
113 }}}}