summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/Config_Handlers/PSPE_Handler.cpp
blob: 2a1b33f8e9916aec5cae5d2934c7eb66ae3f2e7c (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
// $Id$

#include "PSPE_Handler.h"
#include "IDD_Handler.h"
#include "Basic_Deployment_Data.hpp"
#include "ciao/Deployment_DataC.h"

namespace CIAO
{
  namespace Config_Handlers
  {
    bool
    PSPE_Handler::sub_component_port_endpoints (
        const PlanConnectionDescription &src,
        ::Deployment::PlanSubcomponentPortEndpoints &dest)
    {
      PlanConnectionDescription::internalEndpoint_const_iterator iei_e =
        src.end_internalEndpoint ();
      for (PlanConnectionDescription::internalEndpoint_const_iterator iei_b =
             src.begin_internalEndpoint ();
           iei_b != iei_e;
           ++iei_b)
        {
          CORBA::ULong len =
            dest.length ();

          dest.length (len + 1);

          (void) PSPE_Handler::sub_component_port_endpoint (
              (*iei_b),
              dest[len]);
        }
      return true;
    }

    void
    PSPE_Handler::sub_component_port_endpoint (
        const PlanSubcomponentPortEndpoint &src,
        ::Deployment::PlanSubcomponentPortEndpoint &dest)
    {
      dest.portName =
        src.portName ().c_str ();

      if (src.provider_p ())
        {
          dest.provider = !(src.provider ().empty ());
        }
      else
        {
          dest.provider = 0;
        }

      size_t tmp = 0;
      bool r = IDD_Handler::IDREF.find_ref
        (src.instance ().id ().c_str (), tmp);
      ACE_UNUSED_ARG (r);
      
      // @@ MAJO:  What should we do if find_ref fails??
      dest.instanceRef = tmp;

      if (src.kind () == CCMComponentPortKind::Facet)
        dest.kind = Deployment::Facet;
      if (src.kind () == CCMComponentPortKind::SimplexReceptacle)
        dest.kind = Deployment::SimplexReceptacle;
      if (src.kind () == CCMComponentPortKind::MultiplexReceptacle)
        dest.kind = Deployment::MultiplexReceptacle;
      if (src.kind () == CCMComponentPortKind::EventEmitter)
        dest.kind = Deployment::EventEmitter;
      if (src.kind () == CCMComponentPortKind::EventPublisher)
        dest.kind = Deployment::EventPublisher;
      if (src.kind () == CCMComponentPortKind::EventConsumer)
        dest.kind = Deployment::EventConsumer;
    }

    PlanSubcomponentPortEndpoint
    PSPE_Handler::sub_component_port_endpoint (
      const Deployment::PlanSubcomponentPortEndpoint &src)
    { // @@MAJO
      XMLSchema::string< char > pname ((src.portName));
      XMLSchema::string< char > tval  ("true");
      XMLSchema::string< char > prov  ("");
      ACE_CString id;
      IDD_Handler::IDREF.find_ref(src.instanceRef, id);
      XMLSchema::IDREF < ACE_TCHAR > idref(id.c_str()); 
      
      if (src.provider)
        prov = tval;

      PlanSubcomponentPortEndpoint pspe (pname,
					 CCMComponentPortKind::Facet,
					 idref);
      pspe.provider (prov);
      
      if (src.kind == ::Deployment::Facet)
        pspe.kind (CCMComponentPortKind::Facet);
      if (src.kind == ::Deployment::SimplexReceptacle)
        pspe.kind (CCMComponentPortKind::SimplexReceptacle);
      if (src.kind == ::Deployment::MultiplexReceptacle)
        pspe.kind (CCMComponentPortKind::MultiplexReceptacle);
      if (src.kind == ::Deployment::EventEmitter)
        pspe.kind (CCMComponentPortKind::EventEmitter);
      if (src.kind == ::Deployment::EventPublisher)
        pspe.kind (CCMComponentPortKind::EventPublisher);
      if (src.kind == ::Deployment::EventConsumer)
        pspe.kind (CCMComponentPortKind::EventConsumer);

      return pspe;
    }
  }
}