Qpid .NET Messaging API  0.22
Duration.h
Go to the documentation of this file.
00001 /*
00002 * Licensed to the Apache Software Foundation (ASF) under one
00003 * or more contributor license agreements.  See the NOTICE file
00004 * distributed with this work for additional information
00005 * regarding copyright ownership.  The ASF licenses this file
00006 * to you under the Apache License, Version 2.0 (the
00007 * "License"); you may not use this file except in compliance
00008 * with the License.  You may obtain a copy of the License at
00009 *
00010 *   http://www.apache.org/licenses/LICENSE-2.0
00011 *
00012 * Unless required by applicable law or agreed to in writing,
00013 * software distributed under the License is distributed on an
00014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00015 * KIND, either express or implied.  See the License for the
00016 * specific language governing permissions and limitations
00017 * under the License.
00018 */
00019 
00020 #pragma once
00021 
00022 #include <windows.h>
00023 #include <msclr\lock.h>
00024 #include <oletx2xa.h>
00025 #include <string>
00026 #include <limits>
00027 
00028 namespace Org {
00029 namespace Apache {
00030 namespace Qpid {
00031 namespace Messaging {
00032 
00037 
00038     public ref class Duration sealed
00039     {
00040     private:
00041         System::UInt64 milliseconds;
00042 
00043     public:
00044 
00045         Duration(const Duration % rhs) :
00046             milliseconds(rhs.milliseconds) {}
00047 
00048         explicit Duration(System::UInt64 mS) :
00049             milliseconds(mS) {}
00050 
00051         Duration()                           :
00052             milliseconds(System::UInt64::MaxValue) {}
00053 
00054         property System::UInt64 Milliseconds
00055         {
00056             System::UInt64 get () { return milliseconds; }
00057         }
00058 
00059         static Duration ^ operator * (Duration ^ dur, const System::UInt64 multiplier)
00060         {
00061             Duration ^ result = gcnew Duration(dur->Milliseconds * multiplier);
00062             return result;
00063         }
00064 
00065         static Duration ^ operator * (const System::UInt64 multiplier, Duration ^ dur)
00066         {
00067             Duration ^ result = gcnew Duration(multiplier * dur->Milliseconds);
00068             return result;
00069         }
00070 
00071         static Duration ^ Multiply (Duration ^ dur, const System::UInt64 multiplier)
00072         {
00073             Duration ^ result = gcnew Duration(dur->Milliseconds * multiplier);
00074             return result;
00075         }
00076 
00077         static Duration ^ Multiply (const System::UInt64 multiplier, Duration ^ dur)
00078         {
00079             Duration ^ result = gcnew Duration(multiplier * dur->Milliseconds);
00080             return result;
00081         }
00082 
00083         static bool operator == (Duration ^ a, Duration ^ b)
00084         {
00085             return a->Milliseconds == b->Milliseconds;
00086         }
00087 
00088         static bool operator != (Duration ^ a, Duration ^ b)
00089         {
00090             return a->Milliseconds != b->Milliseconds;
00091         }
00092     };
00093 
00094     public ref class DurationConstants sealed
00095     {
00096     private:
00097         DurationConstants::DurationConstants() {}
00098 
00099     public:
00100         static Duration ^ FORVER;
00101         static Duration ^ IMMEDIATE;
00102         static Duration ^ SECOND;
00103         static Duration ^ MINUTE;
00104 
00105         static DurationConstants()
00106         {
00107             FORVER    = gcnew Duration();
00108             IMMEDIATE = gcnew Duration(0);
00109             SECOND    = gcnew Duration(1000);
00110             MINUTE    = gcnew Duration(60000);
00111         }
00112     };
00113 }}}}