summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/NodeApplicationManager/ImplementationInfo.cpp
blob: e4710977c72d1a4417b52be919831e4f68a641bc (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
//$Id$
#ifndef CIAO_IMPLEMENTATION_INFO_C
#define CIAO_IMPLEMENTATION_INFO_C

#include "ImplementationInfo.h"

// Specialized operation that we will use for now.
namespace CIAO
{
  bool operator<< (Deployment::ImplementationInfos & info,
                   const Deployment::DeploymentPlan & plan)
  {
    const CORBA::ULong len = plan.instance.length ();
    info.length (len);

    for (CORBA::ULong i = 0; i < len; ++i)
      {
        const Deployment::InstanceDeploymentDescription & inst =
          plan.instance[i];

        // Get the component instance name.
        info[i].component_instance_name = inst.name.in ();

        const Deployment::MonolithicDeploymentDescription & impl =
          plan.implementation[inst.implementationRef];

        const CORBA::ULong artifact_num = impl.artifactRef.length ();

        // Copy Component instance related Properties if there is any.
        if (inst.configProperty.length () > 0)
          {
            info[i].component_config = inst.configProperty;
          }

        // For svnt artifact
        for (CORBA::ULong j = 0; j < artifact_num; ++j)
          {
            const Deployment::ArtifactDeploymentDescription & arti =
              plan.artifact[ impl.artifactRef[j] ];

            ACE_CString tmp = arti.name.in ();
            ssize_t pos;

            //@@ Note: I am not checking for redundancy here. Maybe
            //         the modeling tool should make sure of
            //         uniqueness.
            if ((pos  = tmp.find ("_svnt")) != ACE_CString::npos ||
                (pos  = tmp.find ("_Svnt")) != ACE_CString::npos)
              {
                if (arti.location.length() < 1 )
                  {
                    ACE_DEBUG ((LM_DEBUG, "Servant Artifact must have a location!\n"));
                    return  0;
                  }
                // Cpoy the servant dll/so name.
                // @@ Note: I ignore all the other locations except the first one.
                info[i].servant_dll = CORBA::string_dup (arti.location[0].in ());

		// Get the entry point.
		const CORBA::ULong prop_length = arti.execParameter.length ();
                for (CORBA::ULong prop_num = 0;
                     prop_num < prop_length;
                     ++prop_num)
                  {
                    ACE_CString name (arti.execParameter[prop_num].name.in ());
                    if (name == ACE_CString ("entryPoint"))
                      {
                        const char * entry;
                        (arti.execParameter[prop_num].value) >>= entry;
                        info[i].servant_entrypt = CORBA::string_dup (entry);
                      }
                    else
                      {
                        ACE_DEBUG ((LM_DEBUG, "Found unknown property in the artifact!\n"));
                        ACE_DEBUG ((LM_DEBUG, "We only support entrypoint at this point in CIAO.\n"));
                      }
                  }
              }
            // As one can see, code is duplicated here. I will come back for this later.
            // For exec artifact
            if ((pos  = tmp.find ("_exec")) != ACE_CString::npos ||
                (pos  = tmp.find ("_Exec")) != ACE_CString::npos)
              {
                if (arti.location.length() < 1 )
                  {
                    ACE_DEBUG ((LM_DEBUG, "Executor Artifact must have a location!\n"));
                    return 0;
                  }
                // Cpoy the servant dll/so name.
                // @@ Note: I ignore all the other locations except the first one.
                info[i].executor_dll = CORBA::string_dup (arti.location[0].in ());

                // Get the entry point.
		const CORBA::ULong prop_length = arti.execParameter.length ();
                for (CORBA::ULong prop_num = 0;
                     prop_num < prop_length;
                     ++prop_num)
                  {
                    ACE_CString name (arti.execParameter[prop_num].name.in ());
                    if (name == ACE_CString ("entryPoint"))
                      {
                        const char * entry;
                        (arti.execParameter[prop_num].value) >>= entry;
                        info[i].executor_entrypt = CORBA::string_dup (entry);
                      }
                    else
                      {
                        ACE_DEBUG ((LM_DEBUG, "Found unknown property in the artifact!\n"));
                        ACE_DEBUG ((LM_DEBUG, "We only support entrypoint at this point in CIAO.\n"));
                      }
                  }
              }

            else
              // We see artifact other than servant/executor and we ignore them.
              continue;
          }
      }
    return 1;
  }
}

#endif /* CIAO_IMPLEMENTATION_INFO_C */