summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/Config_Handlers/PCD_Handler.cpp
blob: 917c056a6cbbc7d41fb4b7b2c12b56f4da81d54f (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// $Id$

#include "PCD_Handler.h"
#include "Req_Handler.h"
#include "CEPE_Handler.h"
#include "PSPE_Handler.h"
#include "ERE_Handler.h"
#include "CRDD_Handler.h"
#include "Basic_Deployment_Data.hpp"
#include "ciao/Deployment_DataC.h"

namespace CIAO
{
  namespace Config_Handlers
  {

    PCD_Handler::PCD_Handler (void)
    {
    }

    PCD_Handler::~PCD_Handler (void)
    {
    }

    ///This method takes a <Deployment::PlanConnectionDescription>
    ///and maps the values from the passed in XSC
    ///PlanConnectionDescription to its members.
    void PCD_Handler::get_PlanConnectionDescription (
                Deployment::PlanConnectionDescription& toconfig,
                PlanConnectionDescription& desc)
    {
      toconfig.name = CORBA::string_dup (desc.name ().c_str ());

      //Source is mapped to a string in the schema and a sequence
      //in the IDL. We just assign the source string from the xml
      //to the first position in the IDL type's sequence. We
      //make sure that the source is present before lengthening
      //the sequence.
      if (desc.source_p ())
        {
          // Only one.....
          toconfig.source.length (1);
          toconfig.source[0] = desc.source ().c_str ();
        }

      for(PlanConnectionDescription::deployRequirement_iterator 
	      req (desc.begin_deployRequirement());
	  req != desc.end_deployRequirement();
	  req++)
        {
#if 0
          // @@ MAJO:
          //Create the handler for the requirements.
          Requirement_Handler reqhandler;

          //Increase the sequence length and delgate
          //the Requirement to the Req_Handler.
          toconfig.deployRequirement.length (
            toconfig.deployRequirement.length () + 1);
          reqhandler.get_Requirement (
            toconfig.deployRequirement[toconfig.deployRequirement.length () - 1],
            desc.deployRequirement ());
#endif /*if 0*/
        }

      //Create the ComponentExternalPortEndpoint handler.
      CEPE_Handler::external_port_endpoints (
	  desc,
	  toconfig.externalEndpoint);
      
      //Configure the PlanSubcomponentPortEndpoint's.

      PSPE_Handler::sub_component_port_endpoints (
	  desc,
	  toconfig.internalEndpoint);

      //Configure the ExternalReferenceEndpoint's.
      ERE_Handler::external_ref_endpoints (
	  desc,
	  toconfig.externalReference);
      
      //Configure the resource value.
      CRDD_Handler crddhandler;
      CORBA::ULong pos = 0;
      toconfig.deployedResource.length (desc.count_deployedResource ());
      for(PlanConnectionDescription::deployedResource_iterator res =
	      desc.begin_deployedResource();
	  res != desc.end_deployedResource();
	  res++)
      {
          crddhandler.get_ConnectionResourceDeploymentDescription (
            toconfig.deployedResource[pos++],
            *res);
      }

    }
      
      PlanConnectionDescription PCD_Handler::get_PlanConnectionDescription (
	  const Deployment::PlanConnectionDescription &src)
      {
	  XMLSchema::string< char > name ((src.name));

	  PlanConnectionDescription pcd(name);

	  //Get the source if it exists
	  if(src.source.length() != 0)
	  {
	      XMLSchema::string< char > source((src.source[0]));
	      pcd.source(source);
	  }

	  //Get any externalEndpoint(s) and store them
	  size_t total = src.externalEndpoint.length();
	  for(size_t i = 0; i < total; i++)
	  {
	      pcd.add_externalEndpoint(
		  CEPE_Handler::external_port_endpoint(
		      src.externalEndpoint[i]));
	  }

	  //Get any externalReference(s) and store them
	  total = src.externalReference.length();
	  for(size_t j = 0; j < total; j++)
	  {
	      pcd.add_externalReference(
		  ERE_Handler::external_ref_endpoint(
		      src.externalReference[j]));
	  }

	  //Get any internalEndpoint(s) and store them
	  total = src.internalEndpoint.length();
	  for(size_t k = 0; k < total; k++)
	  {
	      pcd.add_internalEndpoint(
		  PSPE_Handler::sub_component_port_endpoint(
		      src.internalEndpoint[k]));
	  }
	  
	  //Get any deployedResource(s) and store them
	  total = src.deployedResource.length();
	  for(size_t l = 0; l < total; l++)
	  {
	      pcd.add_deployedResource(
		  CRDD_Handler::connection_resource_depl_desc(
		      src.deployedResource[l]));
	  }

	  //Get any deployRequirement(s) and store them
	  total = src.deployRequirement.length();
	  for(size_t m = 0; m < total; m++)
	  {
	      pcd.add_deployRequirement(
		  Req_Handler::get_requirement(
		      src.deployRequirement[m]));
	  }

	  return pcd;
      }
  }
}