summaryrefslogtreecommitdiff
path: root/cpp/test/uwp/controller/ControllerView.xaml.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2018-12-20 15:44:30 +0100
committerBenoit Foucher <benoit@zeroc.com>2018-12-20 15:44:45 +0100
commite7db6d8028fca5ecfa215ee9adcebdb7879f39de (patch)
tree257dab55cf1181ebfe1089bf16ddb035c647e504 /cpp/test/uwp/controller/ControllerView.xaml.cpp
parentFix csharp .gitignore (diff)
downloadice-e7db6d8028fca5ecfa215ee9adcebdb7879f39de.tar.bz2
ice-e7db6d8028fca5ecfa215ee9adcebdb7879f39de.tar.xz
ice-e7db6d8028fca5ecfa215ee9adcebdb7879f39de.zip
Minor simplifications of C++ test controllers
Diffstat (limited to 'cpp/test/uwp/controller/ControllerView.xaml.cpp')
-rw-r--r--cpp/test/uwp/controller/ControllerView.xaml.cpp82
1 files changed, 37 insertions, 45 deletions
diff --git a/cpp/test/uwp/controller/ControllerView.xaml.cpp b/cpp/test/uwp/controller/ControllerView.xaml.cpp
index 6d8951d7b1b..4d17ef2960b 100644
--- a/cpp/test/uwp/controller/ControllerView.xaml.cpp
+++ b/cpp/test/uwp/controller/ControllerView.xaml.cpp
@@ -47,21 +47,20 @@ public:
ControllerHelperI(const string&, const StringSeq&);
- virtual bool redirect() const;
-
- virtual std::string getOutput() const;
virtual std::string loggerPrefix() const;
- virtual void join();
virtual void print(const std::string&);
virtual void serverReady();
- virtual void shutdown();
-
- virtual int waitSuccess(int) const;
- virtual void waitReady(int) const;
+ virtual void communicatorInitialized(const shared_ptr<Ice::Communicator>&);
void run();
void completed(int);
+ int waitSuccess(int) const;
+ void waitReady(int) const;
+ std::string getOutput() const;
+ void join();
+ void shutdown();
+
private:
string _dll;
@@ -79,7 +78,7 @@ private:
static std::map<std::string, HINSTANCE> _dlls;
HINSTANCE loadDll(const string&);
- unique_ptr<Test::TestHelper> _helper;
+ shared_ptr<Ice::Communicator> _communicator;
};
std::map<std::string, HINSTANCE> ControllerHelperI::_dlls;
@@ -88,7 +87,7 @@ class ProcessI : public Process
{
public:
- ProcessI(const Test::ControllerHelperPtr&);
+ ProcessI(const shared_ptr<ControllerHelperI>&);
void waitReady(int, const Ice::Current&);
int waitSuccess(int, const Ice::Current&);
@@ -96,7 +95,7 @@ public:
private:
- Test::ControllerHelperPtr _controllerHelper;
+ shared_ptr<ControllerHelperI> _controllerHelper;
};
class ProcessControllerI : public ProcessController
@@ -122,7 +121,7 @@ public:
void
registerProcessController(ControllerView^,
- const Ice::ObjectAdapterPtr&,
+ const shared_ptr<Ice::ObjectAdapter>&,
const shared_ptr<ProcessControllerRegistryPrx>&,
const shared_ptr<ProcessControllerPrx>&);
@@ -143,6 +142,18 @@ ControllerHelperI::ControllerHelperI(const string& dll, const StringSeq& args) :
{
}
+string
+ControllerHelperI::loggerPrefix() const
+{
+ return _dll;
+}
+
+void
+ControllerHelperI::print(const std::string& msg)
+{
+ _out << msg;
+}
+
void
ControllerHelperI::serverReady()
{
@@ -151,17 +162,11 @@ ControllerHelperI::serverReady()
_condition.notify_all();
}
-bool
-ControllerHelperI::redirect() const
-{
- return _dll.find("client") != string::npos || _dll.find("collocated") != string::npos;
-}
-
void
-
-ControllerHelperI::print(const std::string& msg)
+ControllerHelperI::communicatorInitialized(const shared_ptr<Ice::Communicator>& communicator)
{
- _out << msg;
+ unique_lock<mutex> lock(_mutex);
+ _communicator = communicator;
}
void
@@ -196,10 +201,11 @@ ControllerHelperI::run()
argv[_args.size()] = 0;
try
{
- StreamHelper streamHelper(this, redirect());
- _helper.reset(createHelper());
- _helper->setControllerHelper(this);
- _helper->run(static_cast<int>(_args.size()), argv);
+ StreamHelper streamHelper(this,
+ _dll.find("client") != string::npos || _dll.find("collocated") != string::npos);
+ auto helper = unique_ptr<Test::TestHelper>(createHelper());
+ helper->setControllerHelper(this);
+ helper->run(static_cast<int>(_args.size()), argv);
completed(0);
}
catch(const std::exception& ex)
@@ -229,6 +235,7 @@ ControllerHelperI::completed(int status)
unique_lock<mutex> lock(_mutex);
_completed = true;
_status = status;
+ _communicator = nullptr;
_condition.notify_all();
}
@@ -270,28 +277,13 @@ ControllerHelperI::getOutput() const
return _out.str();
}
-string
-ControllerHelperI::loggerPrefix() const
-{
- return _dll;
-}
-
void
ControllerHelperI::shutdown()
{
unique_lock<mutex> lock(_mutex);
- if(_completed)
- {
- return;
- }
-
- if(_helper)
+ if(_communicator)
{
- Ice::CommunicatorPtr communicator = _helper->communicator();
- if(communicator)
- {
- communicator->shutdown();
- }
+ _communicator->shutdown();
}
}
@@ -308,7 +300,7 @@ ControllerHelperI::loadDll(const string& name)
return p->second;
}
-ProcessI::ProcessI(const ControllerHelperPtr& controllerHelper) :
+ProcessI::ProcessI(const shared_ptr<ControllerHelperI>& controllerHelper) :
_controllerHelper(controllerHelper)
{
}
@@ -374,7 +366,7 @@ ControllerI::ControllerI(ControllerView^ controller)
auto registry = Ice::uncheckedCast<ProcessControllerRegistryPrx>(
_communicator->stringToProxy("Util/ProcessControllerRegistry:tcp -h 127.0.0.1 -p 15001"));
- Ice::ObjectAdapterPtr adapter = _communicator->createObjectAdapterWithEndpoints("ControllerAdapter", "");
+ shared_ptr<Ice::ObjectAdapter> adapter = _communicator->createObjectAdapterWithEndpoints("ControllerAdapter", "");
Ice::Identity ident = { "ProcessController", "UWP"};
auto processController =
Ice::uncheckedCast<ProcessControllerPrx>(adapter->add(make_shared<ProcessControllerI>(controller), ident));
@@ -385,7 +377,7 @@ ControllerI::ControllerI(ControllerView^ controller)
void
ControllerI::registerProcessController(ControllerView^ controller,
- const Ice::ObjectAdapterPtr& adapter,
+ const shared_ptr<Ice::ObjectAdapter>& adapter,
const shared_ptr<ProcessControllerRegistryPrx>& registry,
const shared_ptr<ProcessControllerPrx>& processController)
{