DDS-PSM-C++  1.0
ISO C++ API for OpenSplice DDS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Reference.hpp
Go to the documentation of this file.
1 #ifndef OMG_DDS_CORE_REFERENCE_HPP_
2 #define OMG_DDS_CORE_REFERENCE_HPP_
3 
4 /* Copyright 2010, Object Management Group, Inc.
5  * Copyright 2010, PrismTech, Inc.
6  * Copyright 2010, Real-Time Innovations, Inc.
7  * All rights reserved.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #include <dds/core/types.hpp>
23 #include <dds/core/refmacros.hpp>
24 #include <dds/core/Exception.hpp>
25 
26 
27 namespace dds { namespace core {
28 
29 
34  template <typename DELEGATE>
35  class Reference
36  {
37  public:
38  DECLARE_TYPE_TRAITS(DELEGATE)
39 
40 
44 
45  public:
51  explicit Reference(const Reference& ref);
52 
58  template <typename D>
59  explicit Reference(const Reference<D>& ref);
60 
61  explicit Reference(DELEGATE_T* p);
62 
63  public:
67  ~Reference();
68 
69  public:
70  operator DELEGATE_REF_T() const;
71 
79  template <typename R>
80  bool operator==(const R& ref) const;
81 
89  template <typename R>
90  bool operator!=(const R& ref) const;
91 
92  template <typename D>
93  Reference& operator=(const Reference<D>& that);
94 
95  template <typename R>
96  Reference& operator=(const R& rhs);
97 
108  Reference&
109  operator=(const null_type);
110 
114  bool is_nil() const;
115 
128  bool
129  operator==(const null_type) const;
130 
143  bool operator!=(const null_type nil) const;
144 
145  private:
146  // -- disallow dynamic allocation for reference types
147  void* operator new(size_t);
148 
149 
150 
151  public:
158  const DELEGATE_REF_T& delegate() const;
159 
166  DELEGATE_REF_T& delegate();
167 
184  DELEGATE* operator->();
185 
202  const DELEGATE* operator->() const;
203 
204  operator DELEGATE_REF_T& ();
205 
206  operator const DELEGATE_REF_T& () const;
207 
208  protected:
209  DELEGATE_REF_T impl_;
210  };
211 
212 
213 } } /* namespace dds / namespace core */
214 
215 template <class D> bool operator == (dds::core::null_type, const dds::core::Reference<D> & r);
216 
217 template <class D> bool operator != (dds::core::null_type, const dds::core::Reference<D> & r);
218 
219 #endif /* OMG_DDS_CORE_REFERENCE_HPP_ */
220