summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-04-14 04:03:52 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-04-14 04:03:52 +0000
commit2418fe7c652d3cdaf9c3ff4e0c4b477d6b7faa1d (patch)
tree193616b0806496cf3ec56f3af52821f2b40f2e3d
parent8d6bafa1ee8e1ec66fc79dfeb56d80e629260c41 (diff)
downloadATCD-2418fe7c652d3cdaf9c3ff4e0c4b477d6b7faa1d.tar.gz
Added the Options class.
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Options.cpp61
-rw-r--r--TAO/orbsvcs/ImplRepo_Service/Options.h63
2 files changed, 124 insertions, 0 deletions
diff --git a/TAO/orbsvcs/ImplRepo_Service/Options.cpp b/TAO/orbsvcs/ImplRepo_Service/Options.cpp
new file mode 100644
index 00000000000..bf4b5cb4f9c
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/Options.cpp
@@ -0,0 +1,61 @@
+// $Id$
+#include "Options.h"
+#include "ace/Get_Opt.h"
+
+// Default Constructor
+Options::Options ()
+: debug_ (1),
+ ior_output_file_ (0)
+{
+ // Nothing
+}
+
+int
+Options::parse_args (int argc, ASYS_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "d:o:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'd': // debug flag.
+ this->debug_ = ACE_OS::atoi (get_opts.optarg);
+ break;
+ case 'o': // output the IOR to a file.
+ this->ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w");
+ if (this->ior_output_file_ == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Error: Unable to open %s for writing: %p\n",
+ get_opts.optarg), -1);
+ break;
+ case '?': // display help for use of the server.*/
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Usage: %s"
+ " [-d] <debug_level>"
+ " [-o] <ior_output_file>"
+ "\n",
+ argv [0]),
+ 1);
+ }
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+// Returns the debug level for the IR.
+
+int
+Options::debug (void) const
+{
+ return this->debug_;
+}
+
+// Returns the file where the IOR should be stored.
+
+FILE *
+Options::output_file (void) const
+{
+ return this->ior_output_file_;
+}
diff --git a/TAO/orbsvcs/ImplRepo_Service/Options.h b/TAO/orbsvcs/ImplRepo_Service/Options.h
new file mode 100644
index 00000000000..d0a4f0492fb
--- /dev/null
+++ b/TAO/orbsvcs/ImplRepo_Service/Options.h
@@ -0,0 +1,63 @@
+/* -*- C++ -*- */
+// $Id $
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/orbsvcs/ImplRepo_Service
+//
+// = FILENAME
+// Options.h
+//
+// = DESCRIPTION
+// This class implements the Options container for the Implementation
+// Repository.
+//
+// = AUTHOR
+// Darrell Brunsch <brunsch@cs.wustl.edu>
+//
+// ============================================================================
+
+#ifndef OPTIONS_H
+#define OPTIONS_H
+
+#include "ace/Singleton.h"
+
+class Options
+{
+ // = TITLE
+ // Maintains the global options.
+ //
+ // = DESCRIPTION
+ // This class is converted into a Singleton by the
+ // <ACE_Singleton> template.
+public:
+ Options ();
+ // Default Constructor
+
+ int parse_args (int argc, ASYS_TCHAR *argv[]);
+ // Parse the command-line arguments and initialize the options.
+
+ int debug (void) const;
+ // Debug level for the IR.
+ // 0 - Quiet
+ // 1 - Trace messages
+ // 2 - Detailed messages
+
+ FILE *output_file (void) const;
+ // Returns the file where the IOR should be stored.
+
+private:
+ unsigned int debug_;
+ // Debug information
+
+ FILE *ior_output_file_;
+ // File where the IOR of the server object is stored.
+
+};
+
+// Typedef an Options Singleton.
+typedef ACE_Singleton <Options, ACE_Null_Mutex> OPTIONS;
+
+#endif /* OPTIONS_H */
+