summaryrefslogtreecommitdiffstats
path: root/argument.hpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2016-11-30 11:29:30 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2016-12-06 20:03:35 +0530
commit835571ebcf22165135429efb0d77f11b92540ecf (patch)
tree7965939f5480fd5cae26faa8834e81bf723d9f0b /argument.hpp
parente1df4321a5e362b9e9c418b1afabc2036663d66c (diff)
downloadphosphor-led-sysfs-835571ebcf22165135429efb0d77f11b92540ecf.tar.gz
phosphor-led-sysfs-835571ebcf22165135429efb0d77f11b92540ecf.zip
Add initial files for physical LED controller
This daemon uses sysfs entry for a particular LED and then triggers necessary action. Name and Path of the LED is needed as command line options to make sure this is genreric implementation. Change-Id: I3d52f1491fcb6ae8119b399a4d2c6770a3f5db30 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'argument.hpp')
-rw-r--r--argument.hpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/argument.hpp b/argument.hpp
new file mode 100644
index 0000000..28b2966
--- /dev/null
+++ b/argument.hpp
@@ -0,0 +1,58 @@
+#ifndef __ARGUMENT_H
+#define __ARGUMENT_H
+#include <getopt.h>
+#include <map>
+#include <string>
+
+namespace phosphor
+{
+namespace led
+{
+/** @brief Class - Encapsulates parsing command line options and
+ * populating arguments
+ */
+class ArgumentParser
+{
+ public:
+ ArgumentParser() = delete;
+ ~ArgumentParser() = default;
+ ArgumentParser(const ArgumentParser&) = delete;
+ ArgumentParser& operator=(const ArgumentParser&) = delete;
+ ArgumentParser(ArgumentParser&&) = default;
+ ArgumentParser& operator=(ArgumentParser&&) = default;
+
+ /** @brief Contructs Argument object
+ *
+ * @param argc - the main function's argc passed as is
+ * @param argv - the main function's argv passed as is
+ * @return Object constructed
+ */
+ ArgumentParser(int argc, char** argv);
+
+ /** @brief Given a option, returns its argument(optarg) */
+ const std::string& operator[](const std::string& opt);
+
+ /** @brief Displays usage */
+ static void usage(char** argv);
+
+ /** @brief Set to 'true' when an option is passed */
+ static const std::string true_string;
+
+ /** @brief Set to '' when an option is not passed */
+ static const std::string empty_string;
+
+ private:
+ /** @brief Option to argument mapping */
+ std::map<const std::string, std::string> arguments;
+
+ /** @brief Array of struct options as needed by getopt_long */
+ static const option options[];
+
+ /** @brief optstring as needed by getopt_long */
+ static const char* optionstr;
+};
+
+} // namespace led
+} // namespace phosphor
+
+#endif
OpenPOWER on IntegriCloud