summaryrefslogtreecommitdiff
path: root/DAnCE/tools/Config_Handlers/Any_Handler.cpp
blob: 1b6ad2d6ca8854a30a77e9e3f15cc4a536dc2585 (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
// $Id$

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

#include "Any_Handler.h"
#include "DataType_Handler.h"
#include "Basic_Deployment_Data.hpp"
#include "tao/AnyTypeCode/Any.h"
#include "dance/Logger/Log_Macros.h"
#include "DynAny_Handler/DynAny_Handler.h"

#include "ace/Null_Mutex.h"

namespace DAnCE
{
  namespace Config_Handlers
  {

    Any_Handler::Any_Handler (void)
    {
      DANCE_TRACE("Any_Handler::constructor");
    }

    Any_Handler::~Any_Handler (void)
    {
      DANCE_TRACE("Any_Handler::destructor");
    }

    void
    Any_Handler::extract_into_any (const Any& desc,
                                   CORBA::Any& toconfig)
    {
      DANCE_TRACE("Any_Handler::extract_into_any");
      try
        {
          DynamicAny::DynAny_var dyn = DYNANY_HANDLER->extract_into_dynany (desc.type (),
                                                                            desc.value ());
          CORBA::Any_var any_safe (dyn->to_any ());
          toconfig = *any_safe;

          dyn->destroy ();
        }
      catch (const CORBA::Exception &ex)
        {
          DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO
                           ACE_TEXT ("Any_Handler::extract_into_any -")
                           ACE_TEXT (" Caught CORBA Exception while extracting into")
                           ACE_TEXT (" dynany: %C\n"),
                           ex._info ().c_str ()));
          throw Config_Error (ACE_TEXT (""),
                              ACE_TEXT ("CORBA Exception while extracting into dynany"));
        }
      catch (Config_Error &ex)
        {
          throw ex;
        }
      catch (...)
        {
          throw Config_Error (ACE_TEXT (""), ACE_TEXT ("Caught error whilst parsing XML into Any"));
        }
    }

    Any Any_Handler::get_any (const ::CORBA::Any& src)
    {
      DANCE_TRACE("Any_Handler::extract_into_any - reverse");

      return DYNANY_HANDLER->extract_from_dynany (src);
    }
  }
}
#include /**/ "ace/post.h"