summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-05-23 14:14:56 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-05-23 14:14:56 (GMT)
commit4ecca617e628e94845dafafbdee46ce57f7bc843 (patch)
tree9113189a54068dd7916bcc377e0d1ff92fc1806b
parent3709f5aa6bc3f458078b9e2b9ded67b75bbbcce4 (diff)
downloaduscxml-4ecca617e628e94845dafafbdee46ce57f7bc843.zip
uscxml-4ecca617e628e94845dafafbdee46ce57f7bc843.tar.gz
uscxml-4ecca617e628e94845dafafbdee46ce57f7bc843.tar.bz2
Builds as plugins again
-rw-r--r--apps/uscxml-browser.cpp2
-rw-r--r--apps/uscxml-transform.cpp2
-rw-r--r--src/uscxml/Factory.cpp33
-rw-r--r--src/uscxml/Factory.h13
-rw-r--r--src/uscxml/Interpreter.cpp5
-rw-r--r--src/uscxml/Interpreter.h2
-rw-r--r--src/uscxml/plugins/invoker/CMakeLists.txt4
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/src/test-datamodel.cpp179
-rw-r--r--test/src/test-stress.cpp2
10 files changed, 49 insertions, 196 deletions
diff --git a/apps/uscxml-browser.cpp b/apps/uscxml-browser.cpp
index 037f9a1..cd74154 100644
--- a/apps/uscxml-browser.cpp
+++ b/apps/uscxml-browser.cpp
@@ -130,7 +130,7 @@ int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
if (options.pluginPath.length() > 0) {
- Factory::pluginPath = options.pluginPath;
+ Factory::setDefaultPluginPath(options.pluginPath);
}
// setup HTTP server
diff --git a/apps/uscxml-transform.cpp b/apps/uscxml-transform.cpp
index 09da679..13fc255 100644
--- a/apps/uscxml-transform.cpp
+++ b/apps/uscxml-transform.cpp
@@ -222,7 +222,7 @@ int main(int argc, char** argv) {
// register plugins
if (pluginPath.length() > 0) {
- Factory::pluginPath = pluginPath;
+ Factory::setDefaultPluginPath(pluginPath);
}
// start HTTP server
diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp
index 2c663b2..378f15e 100644
--- a/src/uscxml/Factory.cpp
+++ b/src/uscxml/Factory.cpp
@@ -126,19 +126,33 @@ namespace uscxml {
Factory::Factory(Factory* parentFactory) : _parentFactory(parentFactory) {
}
-Factory::Factory() {
- _parentFactory = NULL;
+Factory::Factory(const std::string& pluginPath, Factory* parentFactory) : _parentFactory(parentFactory), _pluginPath(pluginPath) {
+ registerPlugins();
+}
+
+Factory::Factory(const std::string& pluginPath) : _parentFactory(NULL), _pluginPath(pluginPath) {
+ registerPlugins();
+}
+
+void Factory::setDefaultPluginPath(const std::string& path) {
+ _defaultPluginPath = path;
+}
+std::string Factory::getDefaultPluginPath() {
+ return _defaultPluginPath;
+}
+
+void Factory::registerPlugins() {
#ifdef BUILD_AS_PLUGINS
- if (pluginPath.length() == 0) {
+ if (_pluginPath.length() == 0) {
// try to read USCXML_PLUGIN_PATH environment variable
- pluginPath = (getenv("USCXML_PLUGIN_PATH") != NULL ? getenv("USCXML_PLUGIN_PATH") : "");
+ _pluginPath = (getenv("USCXML_PLUGIN_PATH") != NULL ? getenv("USCXML_PLUGIN_PATH") : "");
}
- if (pluginPath.length() > 0) {
+ if (_pluginPath.length() > 0) {
pluma.acceptProviderType<InvokerImplProvider>();
pluma.acceptProviderType<IOProcessorImplProvider>();
pluma.acceptProviderType<DataModelImplProvider>();
pluma.acceptProviderType<ExecutableContentImplProvider>();
- pluma.loadFromFolder(pluginPath);
+ pluma.loadFromFolder(_pluginPath);
std::vector<InvokerImplProvider*> invokerProviders;
pluma.getProviders(invokerProviders);
@@ -164,6 +178,9 @@ Factory::Factory() {
LOG(WARNING) << "No path to plugins known, export USCXML_PLUGIN_PATH or pass path as parameter";
}
#else
+ if (_pluginPath.length() > 0)
+ LOG(WARNING) << "Plugin path is given, but uscxml is compiled without support";
+
#if 1
# if (defined UMUNDO_FOUND && defined PROTOBUF_FOUND)
{
@@ -573,7 +590,7 @@ size_t DataModelImpl::replaceExpressions(std::string& content) {
Factory* Factory::getInstance() {
if (_instance == NULL) {
- _instance = new Factory();
+ _instance = new Factory(Factory::_defaultPluginPath);
}
return _instance;
}
@@ -625,5 +642,5 @@ void DataModelImpl::throwErrorPlatform(const std::string& cause) {
Factory* Factory::_instance = NULL;
-std::string Factory::pluginPath;
+std::string Factory::_defaultPluginPath;
} \ No newline at end of file
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h
index 02ce6b8..3a3080a 100644
--- a/src/uscxml/Factory.h
+++ b/src/uscxml/Factory.h
@@ -23,6 +23,7 @@
#include "uscxml/Common.h"
#include "uscxml/Message.h"
#include "uscxml/Convenience.h"
+#include <string.h>
#ifdef BUILD_AS_PLUGINS
#include "Pluma/Pluma.hpp"
@@ -438,6 +439,7 @@ protected:
class USCXML_API Factory {
public:
Factory(Factory* parentFactory);
+ Factory(const std::string& pluginPath, Factory* parentFactory);
void registerIOProcessor(IOProcessorImpl* ioProcessor);
void registerDataModel(DataModelImpl* dataModel);
@@ -453,6 +455,9 @@ public:
static Factory* getInstance();
+ static void setDefaultPluginPath(const std::string& path);
+ static std::string getDefaultPluginPath();
+
std::map<std::string, DataModelImpl*> _dataModels;
std::map<std::string, std::string> _dataModelAliases;
std::map<std::string, IOProcessorImpl*> _ioProcessors;
@@ -461,17 +466,19 @@ public:
std::map<std::string, std::string> _invokerAliases;
std::map<std::pair<std::string, std::string>, ExecutableContentImpl*> _executableContent;
- static std::string pluginPath;
-
protected:
#ifdef BUILD_AS_PLUGINS
pluma::Pluma pluma;
#endif
- Factory();
+ void registerPlugins();
+
+ Factory(const std::string&);
~Factory();
Factory* _parentFactory;
+ std::string _pluginPath;
static Factory* _instance;
+ static std::string _defaultPluginPath;
};
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index e2ee1da..0afdf04 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -104,9 +104,12 @@ void InterpreterOptions::printUsageAndExit(const char* progName) {
printf(" \\\n\t\t[URLN [--disable-http] [--optionN=valueN --optionM=valueM]]");
printf("\n");
printf("Options\n");
+#ifdef BUILD_AS_PLUGINS
+ printf("\t-p : path to the uSCXML plugins (or export USCXML_PLUGIN_PATH)\n");
+#endif
printf("\t-v : be verbose\n");
printf("\t-d : enable debugging via HTTP\n");
- printf("\t-lN : Set loglevel to N\n");
+ printf("\t-lN : set loglevel to N\n");
printf("\t-tN : port for HTTP server\n");
printf("\t-sN : port for HTTPS server\n");
printf("\t-wN : port for WebSocket server\n");
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index 93062e6..3a02cb7 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -138,7 +138,7 @@ public:
};
-class NameSpaceInfo {
+class USCXML_API NameSpaceInfo {
public:
NameSpaceInfo() : nsContext(NULL) {
init(std::map<std::string, std::string>());
diff --git a/src/uscxml/plugins/invoker/CMakeLists.txt b/src/uscxml/plugins/invoker/CMakeLists.txt
index ceb9c90..301f04a 100644
--- a/src/uscxml/plugins/invoker/CMakeLists.txt
+++ b/src/uscxml/plugins/invoker/CMakeLists.txt
@@ -474,8 +474,10 @@ if (MILES_FOUND)
${MILES_LIBRARIES}
${OPENAL_LIBRARY}
${JPEG_LIBRARIES}
- ${ICONV_LIBRARIES}
uscxml)
+ if (ICONV_FOUND)
+ target_link_libraries(invoker_miles ${ICONV_LIBRARIES})
+ endif()
set_target_properties(invoker_miles PROPERTIES FOLDER "Plugin Invoker")
else()
list (APPEND USCXML_FILES ${MILES_INVOKER})
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index b655384..03fd22c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -107,6 +107,9 @@ set_target_properties(test-url PROPERTIES FOLDER "Tests")
add_executable(test-promela-parser src/test-promela-parser.cpp)
target_link_libraries(test-promela-parser uscxml)
+if (BUILD_AS_PLUGINS)
+ target_link_libraries(test-promela-parser datamodel_promela)
+endif()
add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-promela-parser)
set_target_properties(test-promela-parser PROPERTIES FOLDER "Tests")
diff --git a/test/src/test-datamodel.cpp b/test/src/test-datamodel.cpp
index 58f7030..2dced50 100644
--- a/test/src/test-datamodel.cpp
+++ b/test/src/test-datamodel.cpp
@@ -12,191 +12,12 @@
using namespace uscxml;
using namespace boost;
-class TestData {
-public:
- enum Type {
- VERBATIM,
- INTERPRETED,
- };
-
- TestData() : type(INTERPRETED) {}
-
- // TODO: default INTERPRETED is unfortunate
- TestData(const std::string& atom_, Type type_ = INTERPRETED) : atom(atom_), type(type_) {}
- TestData(const char* data, size_t size, const std::string& mimeType, bool adopt = false);
-
- // convenience constructors
- TestData(short atom_) : atom(toStr(atom_)), type(INTERPRETED) {}
- TestData(int atom_) : atom(toStr(atom_)), type(INTERPRETED) {}
- TestData(unsigned int atom_) : atom(toStr(atom_)), type(INTERPRETED) {}
- TestData(long atom_) : atom(toStr(atom_)), type(INTERPRETED) {}
- TestData(unsigned long atom_) : atom(toStr(atom_)), type(INTERPRETED) {}
- TestData(float atom_) : atom(toStr(atom_)), type(INTERPRETED) {}
- TestData(double atom_) : atom(toStr(atom_)), type(INTERPRETED) {}
- TestData(bool atom_) : type(INTERPRETED) {
- if (atom_) {
- atom = "true";
- } else {
- atom = "false";
- }
- }
-
- template <typename T> TestData(T value, Type type_) : atom(toStr(value)), type(type_) {}
-
-#if 0
- // constructor for arbitrary types, skip if type is subclass though (C++11)
- // we will have to drop this constructor as it interferes with operator Data() and entails C++11
- template <typename T>
- Data(T value, typename std::enable_if<! std::is_base_of<Data, T>::value>::type* = nullptr)
- : atom(toStr(value)), type(INTERPRETED) {}
-#endif
-
-
- explicit TestData(const Arabica::DOM::Node<std::string>& dom);
- virtual ~TestData() {}
-
- explicit operator bool() const {
- return (atom.length() > 0 || !compound.empty() || !array.empty() || binary || node);
- }
-
- bool hasKey(const std::string& key) const {
- return (!compound.empty() && compound.find(key) != compound.end());
- }
-
- TestData& operator[](const std::string& key) {
- return operator[](key.c_str());
- }
-
- TestData& operator[](const char* key) {
- return compound[key];
- }
-
- TestData& operator[](const size_t index) {
- while(array.size() < index) {
- array.push_back(TestData("", TestData::VERBATIM));
- }
- std::list<TestData>::iterator arrayIter = array.begin();
- for (int i = 0; i < index; i++, arrayIter++) {}
- return *arrayIter;
- }
-
- const TestData at(const std::string& key) const {
- return at(key.c_str());
- }
-
- const TestData at(const char* key) const {
- if (hasKey(key))
- return compound.at(key);
- TestData data;
- return data;
- }
-
- const TestData item(const size_t index) const {
- if (array.size() < index) {
- std::list<TestData>::const_iterator arrayIter;
- for (int i = 0; i < index; i++, arrayIter++) {}
- return *arrayIter;
- }
- TestData data;
- return data;
- }
-
- bool operator==(const TestData &other) const {
- if (other.atom.size() != atom.size())
- return false;
- if (other.type != type)
- return false;
- if (other.binary != binary)
- return false;
- if (other.array.size() != array.size())
- return false;
- if (other.compound.size() != compound.size())
- return false;
-
- if (other.atom != atom)
- return false;
- if (other.array != array)
- return false;
- if (other.compound != compound)
- return false;
- if (other.node != node)
- return false;
-
- return true;
- }
-
- bool operator!=(const TestData &other) const {
- return !(*this == other);
- }
-
- operator std::string() const {
- return atom;
- }
-
- operator std::map<std::string, TestData>() {
- return compound;
- }
-
- operator std::list<TestData>() {
- return array;
- }
-
- std::map<std::string, TestData> getCompound() {
- return compound;
- }
- void setCompound(const std::map<std::string, TestData>& compound) {
- this->compound = compound;
- }
-
- std::list<TestData> getArray() {
- return array;
- }
- void setArray(const std::list<TestData>& array) {
- this->array = array;
- }
-
- std::string getAtom() {
- return atom;
- }
- void setAtom(const std::string& atom) {
- this->atom = atom;
- }
-
- Type getType() {
- return type;
- }
- void setType(const Type type) {
- this->type = type;
- }
-
- Arabica::DOM::Node<std::string> node;
- std::map<std::string, TestData> compound;
- std::list<TestData> array;
- std::string atom;
- boost::shared_ptr<Blob> binary;
- Type type;
-
-};
-
-
-
-void testConstData(const TestData& data) {
-// std::cout << data.at("foo") << std::endl;
-}
int main(int argc, char** argv) {
#ifdef _WIN32
WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
#endif
-
- {
- TestData data;
- data["foo"] = "bar";
- testConstData(data);
-// std::cout << data << std::endl;
- }
- exit(0);
Interpreter interpreter = Interpreter::fromXML("<scxml></scxml>");
DataModel dm(Factory::getInstance()->createDataModel("ecmascript", interpreter.getImpl().get()));
diff --git a/test/src/test-stress.cpp b/test/src/test-stress.cpp
index 6cce172..6d28829 100644
--- a/test/src/test-stress.cpp
+++ b/test/src/test-stress.cpp
@@ -134,7 +134,7 @@ int main(int argc, char** argv) {
google::InitGoogleLogging(optarg);
break;
case 'p':
- uscxml::Factory::pluginPath = optarg;
+ uscxml::Factory::setDefaultPluginPath(optarg);
break;
case '?':
break;