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
|
// $Id$
#include <iostream>
#include "Deployment.hpp"
#include "PCD_Handler.h"
#include "ciao/Deployment_Packaging_DataC.h"
#include "SID_Handler.h"
#include "ace/Get_Opt.h"
#include "Utils/XML_Helper.h"
#include "tao/ORB.h"
#include "Utils/Exceptions.h"
static const char *input_file = "BasicSP.cdp";
static int
parse_args (int argc, char *argv[])
{
ACE_Get_Opt get_opts (argc, argv, "i:");
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
case 'i':
input_file = get_opts.opt_arg ();
break;
case '?':
default:
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s "
"-i <input file> "
"\n",
argv [0]),
-1);
}
// Indicates sucessful parsing of the command-line
return 0;
}
// Check to see if SRD was imported.
void check_srd (const Deployment::DeploymentPlan &);
using namespace CIAO::Config_Handlers;
int main (int argc, char *argv[])
{
try
{
if (parse_args (argc, argv) != 0)
return 1;
// Initialize an ORB so Any will work
CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv, "");
ACE_UNUSED_ARG (orb);
if (xercesc::DOMDocument *doc = XML_HELPER->create_dom (input_file))
{
::Deployment::PackageConfiguration idl_pc;
{
// //Read in the XSC type structure from the DOMDocument
//PackageConfiguration pc = packageConfiguration (doc);
//std::cerr << "XML to XSC conversion succeeded. Converting to IDL...\n";
//Convert the XSC to an IDL datatype
Packaging::PCD_Handler::package_config (input_file, idl_pc);
std::cout << "Instance document import succeeded. Dumping contents to file\n";
}
// Clear SID_Handler's IDREF Table
Packaging::SID_Handler::IDREF.unbind_refs ();
std::cerr << "Performing IDL->XSC transformation...\n";
PackageConfiguration out_pc (Packaging::PCD_Handler::package_config (idl_pc));
//Create a new DOMDocument for writing the XSC into XML
xercesc::DOMDocument* the_xsc (XML_HELPER->create_dom("Deployment:packageConfiguration",
"http://www.omg.org/Deployment"));
//Serialize the XSC into a DOMDocument
packageConfiguration(out_pc, the_xsc);
//Write it to test.xml
XML_HELPER->write_DOM(the_xsc, "test.xml");
//Cleanliness is next to Godliness
delete doc;
}
std::cout << "Test completed!\n";
}
catch (CIAO::Config_Handlers::Plan_Error &excep)
{
std::cerr << "Plan Error exception caught: " << excep.reason_ << std::endl;
}
catch (CIAO::Config_Handlers::Config_Error &excep)
{
std::cerr << "Config Error " << excep.name_ << ": " << excep.error_ << std::endl;
}
return 0;
}
|