summaryrefslogtreecommitdiff
path: root/TAO/tao/AnyTypeCode/Null_RefCount_Policy.h
blob: 8a39b8e9c5243ce32f27a37aa3bc2fd4ed8ee0d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Null_RefCount_Policy.h
 *
 *  $Id$
 *
 *  Header file for TAO's reference count policy (unrelated to CORBA
 *  policies).
 *
 *  @author Ossama Othman <ossama@dre.vanderbilt.edu>
 */
//=============================================================================

#ifndef TAO_NULL_REFCOUNT_POLICY_H
#define TAO_NULL_REFCOUNT_POLICY_H

#include /**/ "ace/pre.h"

#include "tao/AnyTypeCode/TAO_AnyTypeCode_Export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "tao/Versioned_Namespace.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{

  /**
   * @class Null_RefCount_Policy
   *
   * @brief No-op reference counting policy.
   *
   * This class is intended to be used as a "policy" argument to a
   * host class template that implements no-op reference counting.
   * That class would then inherit privately from it like so:
   *
   * @code
   *   template <class RefCountPolicy>
   *   class MyHostClass : private RefCountPolicy
   *   {
   *   public:
   *     void my_add_ref (void)    { this->RefCountPolicy::add_ref (); }
   *     void my_remove_ref (void) { this->RefCountPolicy::remove_ref (); }
   *   };
   * @endcode
   *
   * and use it like so:
   *
   * @code
   *   typedef MyHostClass<TAO::Null_RefCount_Policy> MyNonRefCountedClass;
   *   MyNonRefCountedClass m;
   *   ...
   * @endcode
   *
   * @note In order to incur no size overhead on the host class due to
   *       virtual tables, no base class defining an interface is
   *       defined.  This allows C++ compilers to apply the Empty Base
   *       Class Optimization.
   */
  class TAO_AnyTypeCode_Export Null_RefCount_Policy
  {
  public:

    /// No-op reference increment.
    void add_ref (void)  { }

    /// No-op reference decrement.
    void remove_ref (void) { }

  };

}  // End namespace TAO

TAO_END_VERSIONED_NAMESPACE_DECL

#include /**/ "ace/post.h"

#endif /* TAO_NULL_REFCOUNT_POLICY_H */