summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/Config_Handlers/IDD_Handler.cpp
blob: 0d60bc4ba260a5fd0c8a7a6dc69ff38507f48aa0 (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
112
113
114
115
116
117
118
119
120
121
// $Id$

#include "IDD_Handler.h"
#include "Prop_Handler.h"
#include "ANY_Handler.h"
#include "Basic_Deployment_Data.hpp"
#include "ciao/Deployment_DataC.h"

namespace CIAO
{
  namespace Config_Handlers
  {

    IDD_Handler::IDD_Handler (void)
    {
    }

    IDD_Handler::~IDD_Handler (void)
    {
    }
 
    ///This method takes a <Deployment::InstanceDeploymentDescription>
    ///and maps the values from the passed in XSC 
    ///InstanceDeploymentDescription to its members.
    void 
    IDD_Handler::get_InstanceDeploymentDescription (
         Deployment::InstanceDeploymentDescription& toconfig,
         InstanceDeploymentDescription& desc)
    {
      // name, node, and source are required elements,
      // and will be present in any valid instance document.
      toconfig.name = CORBA::string_dup (desc.name ().c_str ());
      toconfig.node = CORBA::string_dup (desc.node ().c_str ());
      
      toconfig.source.length (toconfig.source.length () + 1);
      toconfig.source[toconfig.source.length () - 1] = 
        CORBA::string_dup (desc.source ().c_str ());
      
      // @@TODO:  What to do with the implementationRef?
      
      if (desc.configProperty_p ())
        {
          // Create a property handler to fill in a property struct
          Prop_Handler property_handler;
          Deployment::Property prop;
          property_handler.get_Property (prop,
                                         desc.configProperty ());
          
          // Make room in the sequence for the strtuct that we have
          // created.
          toconfig.configProperty.length (toconfig.configProperty.length () + 1);
          toconfig.configProperty[toconfig.configProperty.length () - 1] = 
            prop;
        }

      if (desc.deployedResource_p ())
        {
          CORBA::ULong length = toconfig.deployedResource.length ();
          toconfig.deployedResource.length (length + 1);

          this->get_InstanceResourceDeploymentDescription
            (toconfig.deployedResource[length - 1],
             desc.deployedResource ());
        }
      
      if (desc.deployedSharedResource_p ())
        {
          CORBA::ULong length = toconfig.deployedSharedResource.length ();
          toconfig.deployedSharedResource.length (length + 1);

          this->get_InstanceResourceDeploymentDescription
            (toconfig.deployedResource[length],
             desc.deployedResource ());
        }
      
      // Done!
    }

    void 
    IDD_Handler::get_InstanceResourceDeploymentDescription (
            Deployment::InstanceResourceDeploymentDescription &toconfig,
            InstanceResourceDeploymentDescription &desc)
    {
      // resourceUsage is an enumerated type
      switch (desc.resourceUsage ().integral ())
        {
        case ResourceUsageKind::None_l:
          toconfig.resourceUsage = Deployment::None;
          break;
          
        case ResourceUsageKind::InstanceUsesResource_l:
          toconfig.resourceUsage = Deployment::InstanceUsesResource;
          break;
          
        case ResourceUsageKind::ResourceUsesInstance_l:
          toconfig.resourceUsage = Deployment::ResourceUsesInstance;
          break;
          
        case ResourceUsageKind::PortUsesResource_l:
          toconfig.resourceUsage = Deployment::PortUsesResource;
          break;
          
        case ResourceUsageKind::ResourceUsesPort_l:
          toconfig.resourceUsage = Deployment::ResourceUsesPort;
          break;
        }
      
      // requirementName and resourceName are strings
      toconfig.requirementName = 
        CORBA::string_dup (desc.requirementName ().c_str ());
      toconfig.resourceName = 
        CORBA::string_dup (desc.resourceName ().c_str ());
      
      ANY_Handler::get_Any (toconfig.resourceValue,
                            desc.resourceValue ());
      
      // Done!
    }
    
  }
}