summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/Config_Handlers/DP_Handler.cpp
blob: a236a5328e6fa035a4224e6a62bf101706a1b20c (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
161
162
163
164
165
166
167
168
169
170
171
#include "DP_Handler.h"
#include "ciao/Deployment_DataC.h"

#include "CCD_Handler.h"
#include "ADD_Handler.h"
#include "MDD_Handler.h"
#include "IDD_Handler.h"
#include "ID_Handler.h"
#include "cdp.hpp"

#include "DP_PCD_Handler.h"

ACE_RCSID (Config_Handlers,
           DP_Handler,
           "$Id$")

namespace CIAO
{
  namespace Config_Handlers
  {
    DP_Handler::DP_Handler (DeploymentPlan &dp)
      : idl_dp_ (0)
      , dp_ (dp)
      , retval_ (false)
    {
      if (!this->resolve_plan ())
        throw;
    }

    DP_Handler::~DP_Handler (void)
      throw ()
    {
    }

    ::Deployment::DeploymentPlan const *
    DP_Handler::plan (void) const
      throw (NoPlan)
    {
      if (this->retval_)
        return this->idl_dp_.get ();

      throw NoPlan ();
    }

    ::Deployment::DeploymentPlan *
    DP_Handler::plan (void)
      throw (NoPlan)
    {
      if (this->retval_)
        return this->idl_dp_.release ();

      throw NoPlan ();
    }

    bool
    DP_Handler::resolve_plan (void)
    {
      ::Deployment::DeploymentPlan *tmp =
          new Deployment::DeploymentPlan;

      this->idl_dp_.reset (tmp);

      // Read in the label, if present, since minoccurs = 0
      if (this->dp_.label_p ())
	{
	  this->idl_dp_->label =
	    CORBA::string_dup (this->dp_.label ().c_str ());
	}
      
      // Read in the UUID, if present
      if (this->dp_.UUID_p ())
	{
	  this->idl_dp_->UUID =
	    CORBA::string_dup (this->dp_.UUID ().c_str ());
	}


      // Similar thing for dependsOn
      for (DeploymentPlan::dependsOn_const_iterator dstart = this->dp_.begin_dependsOn ();
	   dstart != this->dp_.end_dependsOn ();
	   ++dstart)
	{
	  CORBA::ULong len =
	    this->idl_dp_->dependsOn.length ();
	  
	  this->idl_dp_->dependsOn.length (len + 1);

	  ID_Handler::get_ImplementationDependency (
             this->idl_dp_->dependsOn [len],
             *dstart);

	}
      
      /* @@ Not needed at this time...

      // ... An the property stuff
      for (DeploymentPlan::infoProperty_const_iterator pstart = this->dp_.begin_infoProperty ();
	   pstart != this->dp_.end_infoProperty ();
	   ++pstart)
	{
	  CORBA::ULong len =
	    this-idl_dp_->infoProperty.length ();

	  this->idl_dp_->infoProperty.length (len + 1);

	  Property_Handler::get_property (
	    *pstart,
	    this->idl_dp_->infoProperty [len]);
	}
      */

      this->retval_ =
        CCD_Handler::component_interface_descr (
          this->dp_.realizes (),
          this->idl_dp_->realizes);

      if (!this->retval_)
        {
          ACE_DEBUG ((LM_ERROR,
                      "(%P|%t) DP_Handler: "
                      "Error parting Component Interface Descriptor."));
          return false;
        }
      

      this->retval_ =
        ADD_Handler::artifact_deployment_descrs (
          this->dp_,
          this->idl_dp_->artifact);

      if (!this->retval_)
        {
          ACE_DEBUG ((LM_ERROR,
                      "(%P|%t) DP_Handler: "
                      "Error parting Artifact Deployment Descriptior."));
          return false;
        }

      this->retval_ =
        MDD_Handler::mono_deployment_descriptions (
          this->dp_,
          this->idl_dp_->implementation);

      if (!this->retval_)
        {
          ACE_DEBUG ((LM_ERROR,
                      "(%P|%t) DP_Handler: "
                      "Error parting Monolithic Deployment Decriptions."));
          return false;
        }
      
      this->retval_ =
        IDD_Handler::instance_deployment_descrs (
          this->dp_,
          this->idl_dp_->instance);

      if (!this->retval_)
        {
          ACE_DEBUG ((LM_ERROR,
                      "(%P|%t) DP_Handler: "
                      "Error parting Instance Deployment Decriptions."));
          return false;
        }

      DP_PCD_Handler::plan_connection_descrs (this->dp_, this->idl_dp_->connection);

      return this->retval_;
    }

  }
}