Qpid .NET Messaging API  0.24
 All Classes Namespaces Files Functions Variables Typedefs
Sender.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/Sender.h"
28 #include "qpid/messaging/Session.h"
29 #include "qpid/messaging/Message.h"
30 
31 namespace qpid {
32 namespace messaging {
33  // Dummy class to satisfy linker
34  class SenderImpl {};
35 }}
36 
37 namespace Org {
38 namespace Apache {
39 namespace Qpid {
40 namespace Messaging {
41 
45 
46  ref class Session;
47  ref class Message;
48 
49  public ref class Sender
50  {
51  private:
52  // The kept object in the Messaging C++ DLL
53  ::qpid::messaging::Sender * nativeObjPtr;
54 
55  // The session that created this Sender
56  Session ^ parentSession;
57 
58  // per-instance lock object
59  System::Object ^ privateLock;
60 
61  // Disallow use after object is destroyed
62  void ThrowIfDisposed();
63 
64  public:
65  // unmanaged clone
66  Sender(const ::qpid::messaging::Sender & s,
67  Session ^ sessRef);
68 
69  // copy constructor
70  Sender(const Sender ^ sender);
71  Sender(const Sender % sender);
72 
73  ~Sender();
74  !Sender();
75 
76  // assignment operator
77  Sender % operator=(const Sender % rhs)
78  {
79  msclr::lock lk(privateLock);
80  ThrowIfDisposed();
81 
82  if (this == %rhs)
83  {
84  // Self assignment, do nothing
85  }
86  else
87  {
88  if (NULL != nativeObjPtr)
89  delete nativeObjPtr;
90  nativeObjPtr = new ::qpid::messaging::Sender(
91  *(const_cast<Sender %>(rhs).NativeSender));
92  parentSession = rhs.parentSession;
93  }
94  return *this;
95  }
96 
97  //
98  // IsDisposed
99  //
100  property bool IsDisposed
101  {
102  bool get()
103  {
104  return NULL == nativeObjPtr;
105  }
106  }
107 
108 
109  //
110  // NativeSender
111  //
112  property ::qpid::messaging::Sender * NativeSender
113  {
114  ::qpid::messaging::Sender * get ()
115  {
116  return nativeObjPtr;
117  }
118  }
119 
120 
121  // Send(message)
122  void Send(Message ^ mmsgp);
123  void Send(Message ^ mmsgp, bool sync);
124 
125  void Close();
126 
127  property System::UInt32 Capacity
128  {
129  System::UInt32 get ()
130  {
131  msclr::lock lk(privateLock);
132  ThrowIfDisposed();
133 
134  return nativeObjPtr->getCapacity();
135  }
136  void set (System::UInt32 capacity)
137  {
138  msclr::lock lk(privateLock);
139  ThrowIfDisposed();
140 
141  nativeObjPtr->setCapacity(capacity);
142  }
143  }
144 
145  property System::UInt32 Unsettled
146  {
147  System::UInt32 get ()
148  {
149  msclr::lock lk(privateLock);
150  ThrowIfDisposed();
151 
152  return nativeObjPtr->getUnsettled();
153  }
154  }
155 
156  property System::UInt32 Available
157  {
158  System::UInt32 get ()
159  {
160  msclr::lock lk(privateLock);
161  ThrowIfDisposed();
162 
163  return nativeObjPtr->getAvailable();
164  }
165  }
166 
167  property System::String ^ Name
168  {
169  System::String ^ get ()
170  {
171  msclr::lock lk(privateLock);
172  ThrowIfDisposed();
173 
174  return gcnew System::String(nativeObjPtr->getName().c_str());
175  }
176  }
177 
178  //
179  // Session
180  //
181  property Org::Apache::Qpid::Messaging::Session ^ Session
182  {
184  {
185  msclr::lock lk(privateLock);
186  ThrowIfDisposed();
187 
188  return parentSession;
189  }
190  }
191  };
192 }}}}