summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/static_configurator/Static_Assembly_Parser.cpp
blob: 27094cb5a3c952b1cc7ac327678a211bbd88b34c (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
// $Id$

#include "Static_Assembly_Visitors.h"
#include "../XML_Helpers/Assembly_Spec.h"
#include "../XML_Helpers/XML_Utils.h"
#include "ace/Get_Opt.h"
#include "ace/streams.h"

char *config_filename = 0;
char *cads_filename = 0;
char *cad_filename = 0;

CIAO::Static_Config::Static_Config_Info static_config_info;

int
parse_args (int argc, char *argv[])
{
  ACE_Get_Opt get_opts (argc, argv, "a:c:");
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'a':
        cad_filename = get_opts.opt_arg ();
        break;

      case 'c': // Get the configuration file for deployment configuration info.
        config_filename = get_opts.opt_arg ();
        break;

      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s \n"
                           "-a <file containing assembly descriptor (.cad) file names>\n"
                           "-c <deployment configuration file>\n"
                           "\n",
                           argv [0]),
                          -1);
      }

  if (cad_filename == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Must specify an assembly descriptor using -a flag.\n"),
                      -1);

  if (config_filename == 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Require a deployment configuration flag.  Use -c to set it \n"
                         ),
                        -1);
    }

  // Indicates sucessful parsing of the command line
  return 0;
}


int
main (int argc, char *argv[])
{
  ACE_TRY_NEW_ENV
    {
      parse_args (argc, argv);
      CIAO::Assembly_Spec assembly_spec;

      if (CIAO::XML_Utils::parse_componentassembly (cad_filename,
                                                    &assembly_spec) != 0)
        {
          ACE_ERROR ((LM_ERROR,
                      "Assembly failed : Invalid assembly location\n"));
        }

      CIAO::Static_Assembly_Builder_Visitor builder (assembly_spec.componentfiles_,
                                                     static_config_info);

      int build_result = assembly_spec.partitioning_.accept (builder
                                                             ACE_ENV_ARG_PARAMETER);

      builder.build_connections (assembly_spec.connections_);

      builder.dump_static_config_info ();
      builder.generate_static_header_file ("Static_Assembly_Config.h");
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "Exception caught:");
      return 1;
    }
  ACE_ENDTRY;

  return 0;
}