Skip to content
Snippets Groups Projects
Commit c4ad123a authored by FBerendsen's avatar FBerendsen
Browse files

COMP: enable c++11 for gcc and other fixes

parent d57de45a
No related branches found
No related tags found
No related merge requests found
PROJECT(componenthandshake)
cmake_minimum_required(VERSION 2.8)
cmake_policy(VERSION 2.8)
ADD_DEFINITIONS(
-std=c++11
)
#set(CMAKE_CXX_STANDARD 11)
file(GLOB componenthandshake_SRC
"*.h"
"*.cxx"
......
#ifndef ComponentBase_h
#define ComponentBase_h
#include <iostream>
#include <cstring>
namespace elx
{
class ComponentBase {
......
......@@ -18,12 +18,12 @@ GDOptimizer4thPartyComponent::~GDOptimizer4thPartyComponent()
int GDOptimizer4thPartyComponent::ConnectFrom(const char * interfacename, ComponentBase* other)
{
//TODO write out as templated functionality:
if (std::strcmp(InterfaceName<InterfaceAcceptor<MetricValueInterface>>::Get(), interfacename) == 0)
if (std::strcmp(InterfaceName<InterfaceAcceptor<MetricValueInterface> >::Get(), interfacename) == 0)
{
InterfaceAcceptor<MetricValueInterface>* acceptIF = static_cast<InterfaceAcceptor<MetricValueInterface>*> (this);
if (!acceptIF)
{
std::cout << InterfaceName<InterfaceAcceptor<MetricValueInterface>>::Get() << " optimizer has no OptimizerValueInterface" << std::endl;
std::cout << InterfaceName<InterfaceAcceptor<MetricValueInterface> >::Get() << " optimizer has no OptimizerValueInterface" << std::endl;
}
// connect value interfaces
acceptIF->Connect(other);
......
......@@ -2,6 +2,7 @@
#define Interfaces_hxx
#include "ComponentBase.h"
#include <typeinfo>
namespace elx
{
......@@ -32,20 +33,6 @@ private:
bool isSet;
};
template<class InterfaceT>
int InterfaceAcceptor<InterfaceT>::Connect(ComponentBase* providerComponent){
InterfaceT* providerInterface = dynamic_cast<InterfaceT*> (providerComponent);
if (!providerInterface)
{
std::cout << "providerComponent does not have required " << InterfaceName < InterfaceT >::Get() << std::endl;
return 0;
}
// connect value interfaces
this->Set(providerInterface); // due to the input argument being uniquely defined in the multiple inheritance tree, all versions of Set() are accessible
return 1;
}
//template<typename... Interfaces>
//class Accepting : public Interfaces...
......@@ -90,8 +77,8 @@ class Providing : public Interfaces...
template<typename AcceptingInterfaces, typename ProvidingInterfaces>
class Implements : public ComponentBase, public AcceptingInterfaces, public ProvidingInterfaces
{
typedef typename AcceptingInterfaces AcceptingInterfacesType;
typedef typename ProvidingInterfaces ProvidingInterfacesType;
typedef AcceptingInterfaces AcceptingInterfacesType;
typedef ProvidingInterfaces ProvidingInterfacesType;
};
/*
......@@ -180,5 +167,20 @@ struct AcceptorInterfaceName
};
template<class InterfaceT>
int InterfaceAcceptor<InterfaceT>::Connect(ComponentBase* providerComponent){
InterfaceT* providerInterface = dynamic_cast<InterfaceT*> (providerComponent);
if (!providerInterface)
{
std::cout << "providerComponent does not have required " << InterfaceName < InterfaceT >::Get() << std::endl;
return 0;
}
// connect value interfaces
this->Set(providerInterface); // due to the input argument being uniquely defined in the multiple inheritance tree, all versions of Set() are accessible
return 1;
}
} // end namespace elx
#endif // #define Interfaces_hxx
\ No newline at end of file
......@@ -13,14 +13,12 @@
using namespace elx;
int main() {
{
tuple<double, long long, const char*> t1(12.2, 42, "big");
std::cout << InterfaceName<MetricValueInterface>::Get() << std::endl;
std::cout << AcceptorInterfaceName<InterfaceAcceptor<MetricValueInterface>>::Get() << std::endl;
std::cout << AcceptorInterfaceName<InterfaceAcceptor<MetricValueInterface> >::Get() << std::endl;
std::cout << InterfaceName<InterfaceAcceptor<MetricValueInterface>>::Get() << std::endl;
std::cout << InterfaceName<InterfaceProvider<MetricValueInterface>>::Get() << std::endl;
std::cout << InterfaceName<InterfaceAcceptor<MetricValueInterface> >::Get() << std::endl;
std::cout << InterfaceName<InterfaceProvider<MetricValueInterface> >::Get() << std::endl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment