summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-13 02:20:15 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-01-13 02:20:15 (GMT)
commitc443aaa23e079d8ab94942bfefa65b940c1acd01 (patch)
treebeab36f1446339fe1b157c349c0808e4f5106982
parenta116aeb2cf5a84fa03f9814c3884561149029267 (diff)
downloaduscxml-c443aaa23e079d8ab94942bfefa65b940c1acd01.zip
uscxml-c443aaa23e079d8ab94942bfefa65b940c1acd01.tar.gz
uscxml-c443aaa23e079d8ab94942bfefa65b940c1acd01.tar.bz2
Fixed bugs intriduced by PIMPL
-rw-r--r--src/uscxml/Factory.cpp6
-rw-r--r--src/uscxml/Factory.h12
-rw-r--r--src/uscxml/Interpreter.cpp1
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp8
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h2
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp4
-rw-r--r--src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h2
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp4
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h2
-rw-r--r--src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp4
-rw-r--r--src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h2
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp10
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h2
-rw-r--r--src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp4
-rw-r--r--src/uscxml/plugins/invoker/umundo/UmundoInvoker.h2
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp6
-rw-r--r--src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h2
-rw-r--r--test/CMakeLists.txt3
-rw-r--r--test/src/test-arabica-events.cpp5
19 files changed, 45 insertions, 36 deletions
diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp
index 478d282..3220225 100644
--- a/src/uscxml/Factory.cpp
+++ b/src/uscxml/Factory.cpp
@@ -175,7 +175,7 @@ boost::shared_ptr<InvokerImpl> Factory::createInvoker(const std::string& type, I
if (factory->_invokers.find(canonicalName) == factory->_invokers.end())
return boost::shared_ptr<InvokerImpl>();
- return boost::shared_ptr<InvokerImpl>(factory->_invokers[canonicalName]->create(interpreter));
+ return boost::static_pointer_cast<InvokerImpl>(factory->_invokers[canonicalName]->create(interpreter));
}
boost::shared_ptr<DataModelImpl> Factory::createDataModel(const std::string& type, Interpreter* interpreter) {
@@ -187,7 +187,7 @@ boost::shared_ptr<DataModelImpl> Factory::createDataModel(const std::string& typ
if (factory->_dataModels.find(canonicalName) == factory->_dataModels.end())
return boost::shared_ptr<DataModelImpl>();
- return boost::shared_ptr<DataModelImpl>(factory->_dataModels[canonicalName]->create(interpreter));
+ return factory->_dataModels[canonicalName]->create(interpreter);
}
boost::shared_ptr<IOProcessorImpl> Factory::createIOProcessor(const std::string& type, Interpreter* interpreter) {
@@ -199,7 +199,7 @@ boost::shared_ptr<IOProcessorImpl> Factory::createIOProcessor(const std::string&
if (factory->_ioProcessors.find(canonicalName) == factory->_ioProcessors.end())
return boost::shared_ptr<IOProcessorImpl>();
- return boost::shared_ptr<IOProcessorImpl>(factory->_ioProcessors[canonicalName]->create(interpreter));
+ return factory->_ioProcessors[canonicalName]->create(interpreter);
}
diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h
index 09bab7b..29f7f9a 100644
--- a/src/uscxml/Factory.h
+++ b/src/uscxml/Factory.h
@@ -29,17 +29,19 @@ template <typename T> T strTo(std::string tmp) {
class Interpreter;
+#if 0
class ExecutableContent {
public:
ExecutableContent() {};
- virtual ExecutableContent* create(Interpreter* interpreter) = 0;
+ virtual boost::shared_ptr<ExecutableContentImpl>* create(Interpreter* interpreter) = 0;
};
-
+#endif
+
class IOProcessorImpl {
public:
IOProcessorImpl() {};
virtual ~IOProcessorImpl() {};
- virtual IOProcessorImpl* create(Interpreter* interpreter) = 0;
+ virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter) = 0;
virtual std::set<std::string> getNames() = 0;
virtual void setInterpreter(Interpreter* interpreter) {
@@ -80,7 +82,7 @@ class InvokerImpl : public IOProcessorImpl {
public:
virtual void invoke(const InvokeRequest& req) = 0;
virtual void sendToParent(const SendRequest& req) = 0;
- virtual InvokerImpl* create(Interpreter* interpreter) = 0;
+ virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter) = 0;
};
class Invoker : public IOProcessor {
@@ -110,7 +112,7 @@ protected:
class DataModelImpl {
public:
virtual ~DataModelImpl() {}
- virtual DataModelImpl* create(Interpreter* interpreter) = 0;
+ virtual boost::shared_ptr<DataModelImpl> create(Interpreter* interpreter) = 0;
virtual std::set<std::string> getNames() = 0;
virtual bool validate(const std::string& location, const std::string& schema) = 0;
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 5681ff9..45ef4b2 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -120,6 +120,7 @@ Interpreter* Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>
LOG(ERROR) << source.getSystemId() << ": no such file";
}
}
+ delete interpreter;
return NULL;
} else {
interpreter->_document = interpreter->Arabica::SAX2DOM::Parser<std::string>::getDocument();
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
index 5ab9b3e..1aa181e 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp
@@ -23,8 +23,8 @@ V8DataModel::V8DataModel() {
// _contexts.push_back(v8::Context::New());
}
-DataModelImpl* V8DataModel::create(Interpreter* interpreter) {
- V8DataModel* dm = new V8DataModel();
+boost::shared_ptr<DataModelImpl> V8DataModel::create(Interpreter* interpreter) {
+ boost::shared_ptr<V8DataModel> dm = boost::shared_ptr<V8DataModel>(new V8DataModel());
dm->_interpreter = interpreter;
v8::Locker locker;
v8::HandleScope scope;
@@ -38,8 +38,8 @@ DataModelImpl* V8DataModel::create(Interpreter* interpreter) {
// some free functions
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
- global->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(dm))), v8::ReadOnly);
- global->Set(v8::String::New("print"), v8::FunctionTemplate::New(jsPrint, v8::External::New(reinterpret_cast<void*>(dm))), v8::ReadOnly);
+ global->Set(v8::String::New("In"), v8::FunctionTemplate::New(jsIn, v8::External::New(reinterpret_cast<void*>(dm.get()))), v8::ReadOnly);
+ global->Set(v8::String::New("print"), v8::FunctionTemplate::New(jsPrint, v8::External::New(reinterpret_cast<void*>(dm.get()))), v8::ReadOnly);
v8::Persistent<v8::Context> context = v8::Context::New(0, global);
v8::Context::Scope contextScope(context);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
index e5c1bc8..7e7bb8d 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h
@@ -21,7 +21,7 @@ class V8DataModel : public DataModelImpl {
public:
V8DataModel();
virtual ~V8DataModel();
- virtual DataModelImpl* create(Interpreter* interpreter);
+ virtual boost::shared_ptr<DataModelImpl> create(Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
index 3e20867..5a33080 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.cpp
@@ -20,8 +20,8 @@ bool connect(pluma::Host& host) {
SWIDataModel::SWIDataModel() {
}
-DataModelImpl* SWIDataModel::create(Interpreter* interpreter) {
- SWIDataModel* dm = new SWIDataModel();
+boost::shared_ptr<DataModelImpl> SWIDataModel::create(Interpreter* interpreter) {
+ boost::shared_ptr<SWIDataModel> dm = boost::shared_ptr<SWIDataModel>(new SWIDataModel());
dm->_interpreter = interpreter;
const char* swiPath = SWI_LIBRARY_PATH;
dm->_plEngine = new PlEngine((char*)swiPath);
diff --git a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
index f5f5247..1d5a454 100644
--- a/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
+++ b/src/uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h
@@ -15,7 +15,7 @@ class SWIDataModel : public DataModelImpl {
public:
SWIDataModel();
virtual ~SWIDataModel();
- virtual DataModelImpl* create(Interpreter* interpreter);
+ virtual boost::shared_ptr<DataModelImpl> create(Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
index 94156c0..08fc1f3 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp
@@ -22,8 +22,8 @@ OSGInvoker::OSGInvoker() {
OSGInvoker::~OSGInvoker() {
};
-InvokerImpl* OSGInvoker::create(Interpreter* interpreter) {
- OSGInvoker* invoker = new OSGInvoker();
+boost::shared_ptr<IOProcessorImpl> OSGInvoker::create(Interpreter* interpreter) {
+ boost::shared_ptr<OSGInvoker> invoker = boost::shared_ptr<OSGInvoker> (new OSGInvoker());
invoker->_interpreter = interpreter;
return invoker;
}
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
index 933ee4a..29f950f 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h
@@ -20,7 +20,7 @@ class OSGInvoker : public InvokerImpl, public Arabica::DOM::Events::EventListene
public:
OSGInvoker();
virtual ~OSGInvoker();
- virtual InvokerImpl* create(Interpreter* interpreter);
+ virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
index eaf5eba..65eed78 100644
--- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
+++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.cpp
@@ -21,8 +21,8 @@ HeartbeatInvoker::HeartbeatInvoker() {
HeartbeatInvoker::~HeartbeatInvoker() {
};
-InvokerImpl* HeartbeatInvoker::create(Interpreter* interpreter) {
- HeartbeatInvoker* invoker = new HeartbeatInvoker();
+boost::shared_ptr<IOProcessorImpl> HeartbeatInvoker::create(Interpreter* interpreter) {
+ boost::shared_ptr<HeartbeatInvoker> invoker = boost::shared_ptr<HeartbeatInvoker>(new HeartbeatInvoker());
invoker->_interpreter = interpreter;
return invoker;
}
diff --git a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h
index 8a90011..bbea7d6 100644
--- a/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h
+++ b/src/uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h
@@ -13,7 +13,7 @@ class HeartbeatInvoker : public InvokerImpl {
public:
HeartbeatInvoker();
virtual ~HeartbeatInvoker();
- virtual InvokerImpl* create(Interpreter* interpreter);
+ virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
index c90ef4d..85f2963 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
@@ -23,8 +23,8 @@ USCXMLInvoker::~USCXMLInvoker() {
delete _invokedInterpreter;
};
-InvokerImpl* USCXMLInvoker::create(Interpreter* interpreter) {
- USCXMLInvoker* invoker = new USCXMLInvoker();
+boost::shared_ptr<IOProcessorImpl> USCXMLInvoker::create(Interpreter* interpreter) {
+ boost::shared_ptr<USCXMLInvoker> invoker = boost::shared_ptr<USCXMLInvoker>(new USCXMLInvoker());
invoker->_parentInterpreter = interpreter;
return invoker;
}
@@ -55,8 +55,10 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) {
if (dataModel) {
}
- _invokedInterpreter->setInvoker(boost::static_pointer_cast<InvokerImpl>(shared_from_this()));
- _invokedInterpreter->start();
+ if (_invokedInterpreter) {
+ _invokedInterpreter->setInvoker(boost::static_pointer_cast<InvokerImpl>(shared_from_this()));
+ _invokedInterpreter->start();
+ }
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
index b1579a2..95de9b2 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
@@ -16,7 +16,7 @@ class USCXMLInvoker : public InvokerImpl, public boost::enable_shared_from_this<
public:
USCXMLInvoker();
virtual ~USCXMLInvoker();
- virtual InvokerImpl* create(Interpreter* interpreter);
+ virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
names.insert("uscxml");
diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
index 3ddc14a..2957078 100644
--- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
+++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp
@@ -28,8 +28,8 @@ UmundoInvoker::~UmundoInvoker() {
}
};
-InvokerImpl* UmundoInvoker::create(Interpreter* interpreter) {
- UmundoInvoker* invoker = new UmundoInvoker();
+boost::shared_ptr<IOProcessorImpl> UmundoInvoker::create(Interpreter* interpreter) {
+ boost::shared_ptr<UmundoInvoker> invoker = boost::shared_ptr<UmundoInvoker>(new UmundoInvoker());
invoker->_interpreter = interpreter;
return invoker;
}
diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h
index 1aa37f2..c5f9656 100644
--- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h
+++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h
@@ -20,7 +20,7 @@ class UmundoInvoker : public InvokerImpl, public umundo::TypedReceiver, public u
public:
UmundoInvoker();
virtual ~UmundoInvoker();
- virtual InvokerImpl* create(Interpreter* interpreter);
+ virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
index 1607e3e..2b6273c 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
+++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp
@@ -46,8 +46,8 @@ EventIOProcessor::~EventIOProcessor() {
httpServer->unregisterProcessor(this);
}
-IOProcessorImpl* EventIOProcessor::create(Interpreter* interpreter) {
- EventIOProcessor* io = new EventIOProcessor();
+boost::shared_ptr<IOProcessorImpl> EventIOProcessor::create(Interpreter* interpreter) {
+ boost::shared_ptr<EventIOProcessor> io = boost::shared_ptr<EventIOProcessor>(new EventIOProcessor());
io->_interpreter = interpreter;
io->_dns = evdns_base_new(io->_asyncQueue._eventLoop, 1);
@@ -56,7 +56,7 @@ IOProcessorImpl* EventIOProcessor::create(Interpreter* interpreter) {
// register at http server
EventIOServer* httpServer = EventIOServer::getInstance();
- httpServer->registerProcessor(io);
+ httpServer->registerProcessor(io.get());
io->start();
return io;
diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
index d3557f4..c90bf79 100644
--- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
+++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h
@@ -28,7 +28,7 @@ public:
EventIOProcessor();
virtual ~EventIOProcessor();
- virtual IOProcessorImpl* create(uscxml::Interpreter* interpreter);
+ virtual boost::shared_ptr<IOProcessorImpl> create(uscxml::Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 353faa2..ae6d07f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -30,7 +30,6 @@ endif()
if (OPENSCENEGRAPH_FOUND)
add_executable(test-osg src/test-osg.cpp)
target_link_libraries(test-osg uscxml)
- add_test(test-osg ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-prolog-swi)
set_target_properties(test-osg PROPERTIES FOLDER "Tests")
endif()
@@ -51,7 +50,7 @@ set_target_properties(test-completion PROPERTIES FOLDER "Tests")
add_executable(test-arabica-events src/test-arabica-events.cpp)
target_link_libraries(test-arabica-events uscxml)
-add_test(test-arabica-events ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-arabica-events ${CMAKE_SOURCE_DIR}/test/samples/arabica/test-arabica-events.xml)
+add_test(test-arabica-events ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-arabica-events ${CMAKE_SOURCE_DIR}/test/samples/uscxml/arabica/test-arabica-events.xml)
set_target_properties(test-arabica-events PROPERTIES FOLDER "Tests")
add_executable(test-url src/test-url.cpp)
diff --git a/test/src/test-arabica-events.cpp b/test/src/test-arabica-events.cpp
index fcf4ea8..13200bb 100644
--- a/test/src/test-arabica-events.cpp
+++ b/test/src/test-arabica-events.cpp
@@ -22,6 +22,11 @@ public:
};
int main(int argc, char** argv) {
+ if (argc != 2) {
+ std::cerr << "Expected path to test-arabica-events.xml" << std::endl;
+ exit(EXIT_FAILURE);
+ }
+
Arabica::SAX::InputSource<std::string> inputSource(argv[1]);
Arabica::SAX2DOM::Parser<std::string> domParser;