diff --git a/CMakeLists.txt b/CMakeLists.txt
index d42a4d63..9486fbd8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,8 @@
# define the minimum cmake version (as required by cmake)
cmake_minimum_required(VERSION 2.8)
-#set(CMAKE_TOOLCHAIN_FILE /opt/raspberrypi/Toolchain-RaspberryPi.cmake)
+
+set(CMAKE_TOOLCHAIN_FILE /home/johan/raspberrypi/Toolchain-RaspberryPi.cmake)
# Define the main-project name
project(Hyperion)
diff --git a/dependencies/build/CMakeLists.txt b/dependencies/build/CMakeLists.txt
index 58e98e7f..00e5ed43 100644
--- a/dependencies/build/CMakeLists.txt
+++ b/dependencies/build/CMakeLists.txt
@@ -7,3 +7,4 @@
# otherwise agree to in writing.
add_subdirectory(jsoncpp)
+add_subdirectory(getoptPlusPlus)
diff --git a/dependencies/build/getoptPlusPlus/getoptpp.cc b/dependencies/build/getoptPlusPlus/getoptpp.cc
index 3b2cb9e3..aae499a9 100644
--- a/dependencies/build/getoptPlusPlus/getoptpp.cc
+++ b/dependencies/build/getoptPlusPlus/getoptpp.cc
@@ -14,10 +14,9 @@
* along with this program. If not, see .
*/
-
-
#include "getoptpp.h"
#include
+#include
using namespace std;
@@ -199,7 +198,8 @@ Parameter::~Parameter() {}
const string& Parameter::description() const { return fdescription; }
const string& Parameter::longOption() const { return flongOption; }
-char Parameter::shortOption() const { return fshortOption; }
+bool Parameter::hasShortOption() const { return fshortOption != 0x0; }
+char Parameter::shortOption() const { assert(hasShortOption()); return fshortOption; }
/*
*
diff --git a/dependencies/include/getoptPlusPlus/getoptpp.h b/dependencies/include/getoptPlusPlus/getoptpp.h
index 902f50c9..23d0aeba 100644
--- a/dependencies/include/getoptPlusPlus/getoptpp.h
+++ b/dependencies/include/getoptPlusPlus/getoptpp.h
@@ -175,15 +175,6 @@ public:
/** Test whether the parameter has been set */
virtual bool isSet() const = 0;
-
- /** Attempt to down-cast to PODParameter.
- *
- * This is very convenient, but also an unholy crime against
- * most principles of sane OOP design.
- */
- template
- T get() const;
-
/** This parameter's line in OptionsParser::usage() */
virtual std::string usageLine() const = 0;
@@ -193,6 +184,9 @@ public:
/** The long name of this parameter (e.g. "--option"), without the dash. */
const std::string& longOption() const;
+ /** Check if this parameters has a short option */
+ bool hasShortOption() const;
+
/** The short name of this parameter (e.g. "-o"), without the dash. */
char shortOption() const;
diff --git a/dependencies/include/getoptPlusPlus/parameter.include.cc b/dependencies/include/getoptPlusPlus/parameter.include.cc
index 199ed6ee..4564d5ec 100644
--- a/dependencies/include/getoptPlusPlus/parameter.include.cc
+++ b/dependencies/include/getoptPlusPlus/parameter.include.cc
@@ -30,16 +30,6 @@ T &ParameterSet::add(char shortName, const char* longName, const char* descripti
return *p;
}
-template
-T Parameter::get() const{
- const PODParameter *ppt = dynamic_cast*>(this);
- if(ppt) {
- return ppt->getValue();
- }
- throw new std::runtime_error("Type conversion not possible");
-}
-
-
/*
*
* Class CommonParameter implementation
@@ -63,8 +53,15 @@ template
std::string CommonParameter::usageLine() const {
std::stringstream strstr;
- strstr.width(10);
+ strstr.width(10);
+ if (hasShortOption())
+ {
strstr << std::left<< std::string("-") + shortOption();
+ }
+ else
+ {
+ strstr << " ";
+ }
strstr.width(20);
strstr << std::left << "--" + longOption();
@@ -82,21 +79,20 @@ bool CommonParameter::receive(ParserState& state) throw(Param
if(arg.at(0) != '-') return false;
if(arg.at(1) == '-') { /* Long form parameter */
-
try {
unsigned int eq = arg.find_first_of("=");
if(eq == std::string::npos) {
- if(arg.substr(2) != longOption())
- return false;
+ if(arg.substr(2) != longOption())
+ return false;
- this->receiveSwitch();
- } else {
- if(arg.substr(2, eq-2) != longOption())
- return false;
+ this->receiveSwitch();
+ } else {
+ if(arg.substr(2, eq-2) != longOption())
+ return false;
- this->receiveArgument(arg.substr(eq+1));
- }
+ this->receiveArgument(arg.substr(eq+1));
+ }
return true;
} catch(Parameter::ExpectedArgument &ea) {
throw ExpectedArgument("--" + longOption() + ": expected an argument");
@@ -112,28 +108,29 @@ bool CommonParameter::receive(ParserState& state) throw(Param
throw Parameter::ParameterRejected("--" + longOption() + " (unspecified error)");
}
}
+ else if (hasShortOption())
+ {
+ try {
+ if(arg.at(1) == shortOption()) {
+ /* Matched argument on the form -f or -fsomething */
+ if(arg.length() == 2) { /* -f */
+ this->receiveSwitch();
- try {
- if(arg.at(1) == shortOption()) {
- /* Matched argument on the form -f or -fsomething */
- if(arg.length() == 2) { /* -f */
- this->receiveSwitch();
-
- return true;
- } else { /* -fsomething */
- this->receiveArgument(arg.substr(2));
-
- return true;
- }
- }
- } catch(Parameter::ExpectedArgument &ea) {
- throw ExpectedArgument(std::string("-") + shortOption() + ": expected an argument");
- } catch(Parameter::UnexpectedArgument &ua) {
- throw UnexpectedArgument(std::string("-") + shortOption() + ": did not expect an argument");
- } catch(Switchable::SwitchingError &e) {
- throw ParameterRejected(std::string("-") + shortOption() + ": parameter already set");
- }
+ return true;
+ } else { /* -fsomething */
+ this->receiveArgument(arg.substr(2));
+ return true;
+ }
+ }
+ } catch(Parameter::ExpectedArgument &ea) {
+ throw ExpectedArgument(std::string("-") + shortOption() + ": expected an argument");
+ } catch(Parameter::UnexpectedArgument &ua) {
+ throw UnexpectedArgument(std::string("-") + shortOption() + ": did not expect an argument");
+ } catch(Switchable::SwitchingError &e) {
+ throw ParameterRejected(std::string("-") + shortOption() + ": parameter already set");
+ }
+ }
} catch(std::out_of_range& o) {
return false;
}
@@ -180,8 +177,15 @@ template
std::string PODParameter::usageLine() const {
std::stringstream strstr;
- strstr.width(10);
- strstr << std::left<< std::string("-") + shortOption() +"arg";
+ strstr.width(10);
+ if (hasShortOption())
+ {
+ strstr << std::left << std::string("-") + shortOption() +"arg";
+ }
+ else
+ {
+ strstr << "";
+ }
strstr.width(20);
strstr << std::left << "--" + longOption() + "=arg";
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dbf76456..c7777ac4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -52,3 +52,5 @@ if(PNG_FOUND)
endif(PNG_FOUND)
add_subdirectory(dispmanx-png)
+add_subdirectory(hyperion-remote)
+
diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp
index 2b9a97a0..2311ffef 100644
--- a/src/hyperion-remote/hyperion-remote.cpp
+++ b/src/hyperion-remote/hyperion-remote.cpp
@@ -20,12 +20,12 @@ int main(int argc, const char * argv[])
StringParameter & argImage = parameters.add('i', "image" , "Set the leds to the colors according to the given image file");
SwitchParameter & argList = parameters.add('l', "list" , "List all priority channels which are in use");
SwitchParameter & argClear = parameters.add('x', "clear" , "Clear data for the priority channel provided by the -p option");
- SwitchParameter & argClearAll = parameters.add('y', "clear-all" , "Clear data for all priority channels");
+ SwitchParameter & argClearAll = parameters.add(0x0, "clear-all" , "Clear data for all priority channels");
DoubleParameter & argGamma = parameters.add('g', "gamma" , "Set the gamma of the leds (requires 3 values)");
DoubleParameter & argThreshold = parameters.add('t', "threshold" , "Set the threshold of the leds (requires 3 values between 0.0 and 1.0)");
DoubleParameter & argBlacklevel = parameters.add('b', "blacklevel", "Set the blacklevel of the leds (requires 3 values which are normally between 0.0 and 1.0)");
DoubleParameter & argWhitelevel = parameters.add('w', "whitelevel", "Set the whitelevel of the leds (requires 3 values which are normally between 0.0 and 1.0)");
- SwitchParameter & argPrint = parameters.add('z', "print" , "Print the json input and output messages on stdout");
+ SwitchParameter & argPrint = parameters.add(0x0, "print" , "Print the json input and output messages on stdout");
SwitchParameter & argHelp = parameters.add('h', "help" , "Show this help message and exit");
try
{