|
// Standard Headers
#include <iostream>
#include <string>
// CppUnitLite Headers
#include "TestHarness.h"
#include "Test.h"
#include "sof/util/threading/SingleThreaded.h"
#include "sof/instantiation/NullCreator.h"
#include "UnitTestLogger.h"
// Standard namespaces
using namespace std;
using namespace sof::util::threading;
using namespace sof::instantiation;
template <class ThreadingModel>
class Foo : public ThreadingModel
{
public:
void doAnything();
};
template <class ThreadingModel>
void Foo<ThreadingModel>::doAnything()
{
cout << "[ThreadingTest#Foo#doAnything] Enter." << endl;
string s;
Lock l;
cout << "[ThreadingTest#Foo#doAnything] Leave." << endl;
}
template <
class ThreadingModel = SingleThreaded,
template <class> class CreationPolicy = NullCreator>
class Bar
{
private:
Foo<ThreadingModel> foo;
public:
void callFoo();
void createObjectFromDll( const string &path, const string &dllName, const string &className );
};
template <
class ThreadingModel,
template <class> class CreationPolicy>
void Bar<ThreadingModel,CreationPolicy>::callFoo()
{
cout << "[ThreadingTest#Bar#callFoo] Enter." << endl;
foo.doAnything();
cout << "[ThreadingTest#Bar#callFoo] Leave." << endl;
}
template <
class ThreadingModel,
template <class> class CreationPolicy>
void Bar<ThreadingModel,CreationPolicy>::createObjectFromDll( const string &path, const string &dllName, const string &className )
{
cout << "[ThreadingTest#Bar#createObjectFromDll] Enter." << endl;
CreationPolicy<string>::createObjectFromDll( path, dllName, className );
cout << "[ThreadingTest#Bar#createObjectFromDll] Leave." << endl;
}
TEST( SingleThreaded, threading1 )
{
UnitTestLogger::getInstance().log( Logger::DEBUG, "[ThreadingTest] *** SingleThreaded-threading1 Test" );
Bar<SingleThreaded,NullCreator> bar;
bar.callFoo();
bar.createObjectFromDll( "a", "b", "c" );
Bar<> bar2;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.