Qpid .NET Messaging API  0.26
 All Classes Namespaces Files Functions Variables Typedefs
Receiver.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 #pragma once
20 
21 #include <windows.h>
22 #include <msclr\lock.h>
23 #include <oletx2xa.h>
24 #include <string>
25 #include <limits>
26 
27 #include "qpid/messaging/Receiver.h"
28 #include "qpid/messaging/Session.h"
29 #include "qpid/messaging/Message.h"
30 #include "qpid/messaging/Duration.h"
31 
32 namespace qpid {
33 namespace messaging {
34  // Dummy class to satisfy linker
35  class ReceiverImpl {};
36 }}
37 
38 namespace Org {
39 namespace Apache {
40 namespace Qpid {
41 namespace Messaging {
42 
46 
47  ref class Session;
48  ref class Message;
49  ref class Duration;
50 
51  public ref class Receiver
52  {
53  private:
54  // The session that created this Receiver
55  Session ^ parentSession;
56 
57  // The kept object in the Messaging C++ DLL
58  ::qpid::messaging::Receiver * nativeObjPtr;
59 
60  // per-instance lock object
61  System::Object ^ privateLock;
62 
63  // Disallow use after object is destroyed
64  void ThrowIfDisposed();
65 
66  public:
67 
68  // unmanaged clone
69  Receiver(const ::qpid::messaging::Receiver & r,
70  Session ^ sessRef);
71 
72  // copy constructor
73  Receiver(const Receiver ^ receiver);
74  Receiver(const Receiver % receiver);
75 
76  // unmanaged clone
77  // undefined
78 
79  ~Receiver();
80  !Receiver();
81 
82  // assignment operator
83  Receiver % operator=(const Receiver % rhs)
84  {
85  msclr::lock lk(privateLock);
86  ThrowIfDisposed();
87 
88  if (this == %rhs)
89  {
90  // Self assignment, do nothing
91  }
92  else
93  {
94  if (NULL != nativeObjPtr)
95  delete nativeObjPtr;
96  nativeObjPtr = new ::qpid::messaging::Receiver(
97  *(const_cast<Receiver %>(rhs).NativeReceiver));
98  parentSession = rhs.parentSession;
99  }
100  return *this;
101  }
102 
103  //
104  // IsDisposed
105  //
106  property bool IsDisposed
107  {
108  bool get()
109  {
110  return NULL == nativeObjPtr;
111  }
112  }
113 
114 
115  //
116  // NativeReceiver
117  //
118  property ::qpid::messaging::Receiver * NativeReceiver
119  {
120  ::qpid::messaging::Receiver * get ()
121  {
122  return nativeObjPtr;
123  }
124  }
125 
126  // Get(message)
127  bool Get(Message ^% mmsgp);
128  bool Get(Message ^% mmsgp, Duration ^ durationp);
129 
130  // message = Get()
131  Message ^ Get();
132  Message ^ Get(Duration ^ durationp);
133 
134  // Fetch(message)
135  bool Fetch(Message ^% mmsgp);
136  bool Fetch(Message ^% mmsgp, Duration ^ duration);
137 
138  // message = Fetch()
139  Message ^ Fetch();
140  Message ^ Fetch(Duration ^ durationp);
141 
142  //
143  // Capacity
144  //
145  property System::UInt32 Capacity
146  {
147  void set (System::UInt32 capacity)
148  {
149  msclr::lock lk(privateLock);
150  ThrowIfDisposed();
151 
152  nativeObjPtr->setCapacity(capacity);
153  }
154 
155  System::UInt32 get ()
156  {
157  msclr::lock lk(privateLock);
158  ThrowIfDisposed();
159 
160  return nativeObjPtr->getCapacity();
161  }
162  }
163 
164  //
165  // Available
166  //
167  property System::UInt32 Available
168  {
169  System::UInt32 get ()
170  {
171  msclr::lock lk(privateLock);
172  ThrowIfDisposed();
173 
174  return nativeObjPtr->getAvailable();
175  }
176  }
177 
178  //
179  // Unsettled
180  //
181  property System::UInt32 Unsettled
182  {
183  System::UInt32 get ()
184  {
185  msclr::lock lk(privateLock);
186  ThrowIfDisposed();
187 
188  return nativeObjPtr->getUnsettled();
189  }
190  }
191 
192  void Close();
193 
194  //
195  // IsClosed
196  //
197  property System::Boolean IsClosed
198  {
199  System::Boolean get ()
200  {
201  msclr::lock lk(privateLock);
202  ThrowIfDisposed();
203 
204  return nativeObjPtr->isClosed();
205  }
206  }
207 
208  //
209  // Name
210  //
211  property System::String ^ Name
212  {
213  System::String ^ get ()
214  {
215  msclr::lock lk(privateLock);
216  ThrowIfDisposed();
217 
218  return gcnew System::String(nativeObjPtr->getName().c_str());
219  }
220  }
221 
222  //
223  // Session
224  //
225  property Org::Apache::Qpid::Messaging::Session ^ Session
226  {
228  {
229  msclr::lock lk(privateLock);
230  ThrowIfDisposed();
231 
232  return parentSession;
233  }
234  }
235  };
236 }}}}
Message Fetch()
Definition: Receiver.cpp:297
property bool IsDisposed
Definition: Receiver.h:107
Receiver(const ::qpid::messaging::Receiver &r, Session^sessRef)
Definition: Receiver.cpp:55
Message Get()
Definition: Receiver.cpp:200
~Receiver()
Definition: Receiver.cpp:82
Receiver operator=(const Receiver%rhs)
Definition: Receiver.h:83
property System::UInt32 Capacity
Definition: Receiver.h:146
Definition: Receiver.h:35