fw4spl
GenericExecutableFactory.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWRUNTIME_UTILS_GENERICEXECUTABLEFACTORY_HPP__
8 #define __FWRUNTIME_UTILS_GENERICEXECUTABLEFACTORY_HPP__
9 
10 #include <sstream>
11 #include <string>
12 
13 #include "fwRuntime/Bundle.hpp"
14 #include "fwRuntime/ExecutableFactory.hpp"
15 
16 
17 namespace fwRuntime
18 {
19 namespace utils
20 {
21 
22 
29 template<typename E>
31 {
37  GenericExecutableFactory(const std::string& type)
38  : ExecutableFactory( type )
39  {
40  }
41 
46  {
47  }
48 
49 
56  {
57  IExecutable * result( 0 );
58  try
59  {
60  result = new E();
61  }
62  catch( std::exception & exception )
63  {
64  std::ostringstream buffer;
65  buffer << "Unexpected exception caught while creating an ::fwRuntime::IExecutable instance. ";
66  buffer << exception.what();
67  throw RuntimeException( buffer.str() );
68  }
69  catch( ... )
70  {
71  throw RuntimeException( "Unexpected exception caught while creating an ::fwRuntime::IExecutable instance." );
72  }
73  return result;
74  }
75 
76 
77  private:
78 
84  void operator=(const GenericExecutableFactory&) noexcept
85  {
86  }
87 
88 };
89 
90 
91 } // namespace utils
92 
93 } // namespace fwRuntime
94 
95 
96 #endif // __FWRUNTIME_UTILS_GENERICEXECUTABLEFACTORY_HPP__
Defines the abstract executable factory class.
Defines the runtime exception class.
Defines the base executable interface.An executable object is an instance created by an extension poi...
Definition: IExecutable.hpp:41
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
IExecutable * createExecutable() const
Creates an executable object instance.
GenericExecutableFactory(const std::string &type)
Constructor.
virtual ~GenericExecutableFactory()
Destructor : does nothing.
Defines a generic template executable factory class.