summaryrefslogtreecommitdiff
path: root/trunk/TAO/tao/AnyTypeCode/RefCount_Policy_Traits.h
blob: d5e4f08d50d129779ef9f7b36a4c414ab0b7f1d4 (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
// -*- C++ -*-

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

#ifndef TAO_REFCOUNT_POLICY_TRAITS_H
#define TAO_REFCOUNT_POLICY_TRAITS_H

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

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

#include "tao/AnyTypeCode/AnyTypeCode_methods.h"


TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  class Null_RefCount_Policy;
  class True_RefCount_Policy;

  /**
   * @struct RefCount_Policy_Traits
   *
   * @brief Compile-time selection of RefCount_Policy operations,
   *        etc.
   *
   * This primary template is used to select RefCount_Policy
   * operations, etc at compile-time based on the reference counting
   * policy and type being operated on.
   *
   * @note This merely a forward declaration since we really only care
   *       about the partial specializations below.
   */
  template<class RefCountPolicy, typename TypePtr>
  struct RefCount_Policy_Traits;

  /**
   * @struct RefCount_Policy_Traits
   *
   * @brief No-op reference count policy traits.
   *
   * This partial specialization performs no-op reference counting
   * operations on values of type @a TypePtr if the @a RefCountPolicy
   * first argument is @c Null_RefCount_Policy.
   */
  template<typename TypePtr>
  struct RefCount_Policy_Traits<Null_RefCount_Policy, TypePtr>
  {
    /// No-op "release" operation.
    static void release (TypePtr) { }
  };

  template<typename TypePtr>
  struct RefCount_Policy_Traits<True_RefCount_Policy, TypePtr>
  {
    /// Call actual "release" operation on @a ptr value.
    static void release (TypePtr ptr)
    {
      CORBA::release (ptr);
    }
  };
}  // End namespace TAO

TAO_END_VERSIONED_NAMESPACE_DECL

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

#endif /* TAO_REFCOUNT_POLICY_TRAITS_H */