summaryrefslogtreecommitdiff
path: root/TAO/tao/Any_Insert_Policy_T.h
blob: 8fb6594831119259873dd9d8ebe5cda44152973f (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Any_Insert_Policy_T.h
 *
 *  @author Johnny Willemsen  <jwillemsen@remedy.nl>
 */
//=============================================================================

#ifndef TAO_ANY_INSERT_POLICY_H
#define TAO_ANY_INSERT_POLICY_H

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

#include "tao/UB_String_Argument_T.h"

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

#include "tao/Arg_Traits_T.h"
#include "tao/Argument.h"
#include "tao/AnyTypeCode_Adapter.h"

#include "ace/Dynamic_Service.h"
#include "ace/Log_Msg.h"
#include "tao/debug.h"
#include "tao/IFR_Client_Adapter.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  template <typename S>
  class Any_Insert_Policy_Stream
  {
  public:
    static inline void any_insert (CORBA::Any* p, S const & x)
      {
        (*p) <<= x;
      }
  };

  template <typename S>
  class Any_Insert_Policy_AnyTypeCode_Adapter
  {
  public:
    static inline void any_insert (CORBA::Any* p, S const & x)
      {
        TAO_AnyTypeCode_Adapter *adapter =
          ACE_Dynamic_Service<TAO_AnyTypeCode_Adapter>::instance (
              "AnyTypeCode_Adapter");

        if (adapter)
          {
            adapter->insert_into_any (p, x);
          }
        else
          {
            TAOLIB_ERROR ((LM_ERROR,
                        ACE_TEXT ("(%P|%t) %p\n"),
                        ACE_TEXT ("ERROR: unable to find AnyTypeCode Adapter ")));
          }
      }
  };

  template <typename S>
  class Any_Insert_Policy_IFR_Client_Adapter
  {
  public:
    static inline void any_insert (CORBA::Any* p, S const & x)
      {
        TAO_IFR_Client_Adapter *adapter =
          ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (
              "Concrete_IFR_Client_Adapter");

        adapter->interfacedef_any_insert (p, x);
      }
  };

  template <typename S>
  class Any_Insert_Policy_Noop
  {
  public:
    static inline void any_insert (CORBA::Any* , S const &)
      {
      }
  };

  template <typename S>
  class Any_Insert_Policy_CORBA_Object
  {
  public:
    static inline void any_insert (CORBA::Any* , S const &)
      {
        if (TAO_debug_level > 2)
          {
            TAOLIB_DEBUG ((LM_DEBUG,
                        "TAO (%P|%t) - Cannot insert a vanilla CORBA Object"
                        " into an Any for returning the return value.\n"));
          }
      }
  };
}

TAO_END_VERSIONED_NAMESPACE_DECL

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

#endif /* TAO_ANY_INSERT_POLICY_H */