summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/spec_RepositoryManager/Options.cpp
blob: 45227d1741b7d8af9582fa77f55a5b076c126de9 (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
// $Id$

// Options.cpp,v Stoyan

#include "ace/Get_Opt.h"
#include "ace/ARGV.h"
#include "Options.h"

Options *Options::instance_ = 0;

Options *
Options::instance (void)
{

  if (Options::instance_ == 0) 
    Options::instance_ = new Options;

  return Options::instance_;
}

void
Options::parse_args (int argc, ACE_TCHAR *argv[])
{
	ACE_Get_Arg_Opt<char> get_opt (argc, argv, ACE_TEXT ("n:l:u:ifds"));

  int c;

  while ((c = get_opt ()) != -1)
    switch (c)
      {
      case 'i':
        this->install_ = true;
        break;
      case 'd':
        this->delete_ = true;
        break;
      case 'f':
        this->find_ = true;
        break;
	  case 's':
        this->shutdown_ = true;
        break;
      case 'n':
        this->name_ = get_opt.opt_arg ();
        break;
      case 'l':
        this->path_ = get_opt.opt_arg ();
        break;
      case 'u':
        this->uuid_ = get_opt.opt_arg ();
        break;
        // Usage fallthrough.
      default:
		  this->usage ();
		  
      }

  if ((this->name_ == "") && (this->shutdown_ == false) && (this->uuid_ == "")) 
	  this->usage ();
  else if (this->name_ != "")
  {
	if (!(this->install_ || this->find_ || this->delete_))
	  this->usage ();
    else if (this->install_ && this->path_ == "")
	  this->usage ();
  }
  else if (this->uuid_ != "" && !this->find_)
	  this->usage ();
}

void Options::usage (void)
{
	ACE_DEBUG ((LM_DEBUG, "OPTIONS: -s <shutdown> -n <:name> [-i <install> -l <:path>] \
						  [-d <delete>] [-f <find>] [-u <:uuid>]\n"));
    ACE_OS::exit (1);
}


Options::Options (void) 
  : name_ (""),
    uuid_ (""),
	path_ (""),
	delete_ (false),
	install_ (false),
	find_ (false),
	shutdown_ (false)
{
}