summaryrefslogtreecommitdiff
path: root/trunk/TAO/orbsvcs/performance-tests/RTEvent/lib/Servant_var.h
blob: 4d035f8b43c8e282bf1953b14d8f5cfab3de510b (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
/**
 * @file Servant_var.h
 *
 * $Id$
 *
 * @author Jody Hagins <jody@atdesk.com>
 * @author Carlos O'Ryan <coryan@uci.edu>
 */
#ifndef TAO_PERF_RTEC_SERVANT_VAR_H
#define TAO_PERF_RTEC_SERVANT_VAR_H

#include "ace/Swap.h"
#include "tao/corba.h"

/**
 * @class Servant_var
 *
 * @brief Implement a smart pointer class for Servants
 *
 * All servants, are reference counted objects.
 * Unfortunately the specification lacks such an useful smart pointer
 * class to manage their life-cycle.
 */
template<class SERVANT>
class Servant_var
{
public:
  /// Constructor
  /**
   * @param s The contained servant.  The constructor assumes
   * ownership.
   */
  explicit Servant_var (SERVANT *s = 0);

  /// Copy constructor
  Servant_var (const Servant_var<SERVANT> &rhs);

  /// Assignment
  Servant_var<SERVANT>& operator= (const Servant_var<SERVANT> &rhs);

  /// Assignment
  Servant_var<SERVANT>& operator= (SERVANT *s);

  /// Destructor
  ~Servant_var ();

  /// Helper method to increase the reference count on a servant.
  static SERVANT *duplicate (SERVANT *servart);

  //@{
  /** @name Smart pointer operations
   */
  const SERVANT * operator->() const;
  SERVANT * operator->();

  operator SERVANT *();
  operator const SERVANT * () const;
  //@}

  //@{
  /** @name Canonical CORBA T_var methods
   */
  SERVANT *in () const;
  SERVANT *&out ();
  SERVANT *&inout ();
  //@}

private:
  /// The owned object
  SERVANT *ptr_;
};

#if defined(__ACE_INLINE__)
#include "Servant_var.inl"
#endif /* __ACE_INLINE__ */

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "Servant_var.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#endif /* TAO_PERF_RTEC_SERVANT_VAR_H */