summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp
blob: 3facc261b5adf64bd5a3eee5881380116525c150 (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
// $Id$

#include "Configurator_Factory.h"
#include "NoOp_Configurator.h"
#include "ace/Null_Mutex.h"
#include "ciao/CIAO_common.h"
#include "ace/Arg_Shifter.h"


int
CIAO::NodeApplication_Options::parse_args (int argc, char *argv[])
{
  //  ACE_Get_Opt get_opts (argc, argv, "nrk:o:");
  ACE_Arg_Shifter shifter (argc, argv);

  while (shifter.is_anything_left ()) {
    const char *parm = 0;

    if (shifter.cur_arg_strncasecmp ("-n") == 0) // Use callback.
      {
        this->use_callback_ = 0;
        shifter.consume_arg ();
      }
    else if (shifter.cur_arg_strncasecmp ("-r") == 0)
      {
        this->rt_support_ = 1;
        shifter.consume_arg ();
      }
    else if (ACE_OS::strncmp (shifter.get_current (),
                              "-ORB",
                              ACE_OS::strlen ("-ORB")) == 0)
      {
        // Ignore ORB parameter
        shifter.ignore_arg ();
      }
    else if ((parm = shifter.get_the_parameter ("-o")) !=0)
      {
        this->ior_output_filename_ = parm;
        shifter.consume_arg ();
      }
    else if ((parm = shifter.get_the_parameter ("-k")) !=0)
      {
        this->callback_ior_ = parm;
        shifter.consume_arg ();
      }
    else if (shifter.cur_arg_strncasecmp ("-h") == 0)
      {
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s\n"
                           "-n Do not use Callback (for testing)\n"
                           "-o <ior_output_file>\n"
                           "-k <NodeApplicationManager_callback_ior>\n"
                           "-r Request RT support\n"
                           "-h Usage help"
                           "\n",
                           argv [0]),
                          -1);
        shifter.consume_arg ();
      }
    else
      shifter.ignore_arg ();

  }

  if (this->use_callback_ && this->callback_ior_.length() == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Callback IOR to NodeApplicationManager is required.\n"),
                      -1);

  return 0;
}

CIAO::NodeApp_Configurator *
CIAO::NodeApplication_Options::create_nodeapp_configurator (void)
{
  typedef CIAO::NodeApp_Configurator * (*intelligent_designer)(void);

  CIAO::NodeApp_Configurator* ptr = 0;

  if (this->rt_support_)
    {
      int retval = this->config_dll_.open
        (ACE_DLL_PREFIX ACE_TEXT("CIAO_RTNA_Configurator"),
         ACE_DEFAULT_SHLIB_MODE, 0);

      if (retval != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "%p\n",
                           "dll.open"),
                          0);
      intelligent_designer config_id; // "id" is for intelligent-designer

      config_id = (intelligent_designer) this->config_dll_.symbol (ACE_TEXT("create_nodeapp_configurator"));

      if (config_id == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "%p",
                           "dll.symbol"),
                          0);
      ptr = config_id ();
      if (ptr == 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Error creating RTNodeApp_Configurator\n"),
                          0);
    }
  else
    ACE_NEW_RETURN (ptr,
                    CIAO::NoOp_Configurator (),
                    0);

  return ptr;
}