7 #ifndef __FWRUNTIME_OPERATIONS_HPP__ 8 #define __FWRUNTIME_OPERATIONS_HPP__ 10 #include "fwRuntime/config.hpp" 11 #include "fwRuntime/ConfigurationElement.hpp" 12 #include "fwRuntime/Executable.hpp" 13 #include "fwRuntime/Extension.hpp" 14 #include "fwRuntime/ExtensionPoint.hpp" 15 #include "fwRuntime/Runtime.hpp" 16 #include "fwRuntime/RuntimeException.hpp" 17 #include "fwRuntime/Version.hpp" 19 #include <fwCore/base.hpp> 21 #include <boost/filesystem/path.hpp> 47 FWRUNTIME_API std::shared_ptr<ExtensionPoint>
findExtensionPoint(
const std::string& identifier );
62 const std::shared_ptr<Extension> extension,
63 const std::string& element =
"executable",
64 const std::string& attribute =
"class" )
67 std::shared_ptr<ConfigurationElement> elt( extension->findConfigurationElement(element) );
70 throw RuntimeException(element +
": configuration element not found in extension.");
74 return createExecutableInstance<T>( elt, attribute );
88 const std::shared_ptr<ConfigurationElement> element,
89 const std::string& attribute =
"class" )
93 if( element->hasAttribute( attribute ) == false )
95 throw RuntimeException(
"Configuration element has no attribute '" + attribute +
"'." );
97 const std::string type( element->getExistingAttributeValue(attribute) );
101 std::unique_ptr< IExecutable > executable( rntm->createExecutableInstance(type, element) );
104 T* result =
dynamic_cast<T*
>( executable.get() );
109 executable.release();
122 template<
typename OutputIterator>
124 const std::string& identifier,
125 OutputIterator output
132 throw RuntimeException( identifier +
": invalid extension point identifier." );
134 point->getAllExtensions( output );
145 template<
typename OutputIterator>
147 const std::string& identifier,
148 OutputIterator output
153 OSLM_TRACE(
"getAllConfigurationElementsForPoint(" << identifier <<
"Bundle" <<
154 point->getBundle()->getIdentifier() );
158 throw RuntimeException( identifier +
": invalid extension point identifier." );
162 if ( point->isEnable() )
164 point->getAllConfigurationElements( output );
168 OSLM_DEBUG(
"IGNORING getAllConfigurationElementsForPoint(" << identifier <<
") extension point disabled");
184 template<
typename Container>
188 typedef std::back_insert_iterator< Container > Inserter;
192 Inserter inserter(elements);
212 template<
typename Container,
typename T >
214 const std::string& attribute =
"class" )
220 ConfigurationElementContainer elements( getAllConfigurationElementsForPoint< ConfigurationElementContainer >(
224 typedef std::back_insert_iterator< Container > Inserter;
228 ConfigurationElementContainer::iterator iElement;
229 Inserter iInserter( result );
230 for( iElement = elements.
begin(); iElement != elements.
end(); ++iElement, ++iInserter )
232 std::shared_ptr< ConfigurationElement > element( *iElement );
233 std::shared_ptr< T > executable( createExecutableInstance< T >(element, attribute) );
235 iInserter = executable;
250 const std::string& pointIdentifier );
259 FWRUNTIME_API std::shared_ptr<Extension>
findExtension(
const std::string& identifier );
268 FWRUNTIME_API ::boost::filesystem::path
getBundleResourcePath(
const std::string& bundleIdentifier) noexcept;
279 const ::boost::filesystem::path& path) noexcept;
321 FWRUNTIME_API ::boost::filesystem::path
getResourceFilePath(const ::boost::filesystem::path& path) noexcept;
332 const ::boost::filesystem::path& path) noexcept;
342 FWRUNTIME_API ::boost::filesystem::path
getBundleResourcePath( std::shared_ptr<ConfigurationElement> element,
343 const ::boost::filesystem::path& path) noexcept;
354 const ::boost::filesystem::path& path) noexcept;
361 FWRUNTIME_API
void addBundles(
const boost::filesystem::path& directory );
370 FWRUNTIME_API std::shared_ptr< ::fwRuntime::profile::Profile >
startProfile(
const boost::filesystem::path& path );
380 FWRUNTIME_API std::shared_ptr<Bundle>
findBundle(
const std::string& identifier,
const Version& version =
Version() );
387 FWRUNTIME_API
void startBundle(
const std::string& identifier);
391 #endif // __FWRUNTIME_OPERATIONS_HPP__ static FWRUNTIME_API Runtime * getDefault()
Retrieves the default runtime instance.
Defines the runtime class.
FWRUNTIME_API::boost::filesystem::path getLibraryResourceFilePath(const ::boost::filesystem::path &path) noexcept
Retrieve a filesystem valid path for a resource path whose first element is a library identifier...
FWRUNTIME_API::boost::filesystem::path getResourceFilePath(const ::boost::filesystem::path &path) noexcept
Retrieve a filesystem valid path for a resource path whose first element is a library or a bundle ide...
FWRUNTIME_API std::shared_ptr< ConfigurationElement > findConfigurationElement(const std::string &identifier, const std::string &pointIdentifier)
Retrieve the configuation element with the given identifier for the given extension point...
FWRUNTIME_API Iterator begin()
Retrieves the iterator on the first managed configuration element.
Defines the runtime exception class.
const Container getAllExecutableForPoint(const std::string &identifier, const std::string &attribute="class")
Retrieves all executable objects for the point having the specified identifier.
Defines the base executable interface.An executable object is an instance created by an extension poi...
FWRUNTIME_API std::shared_ptr< Extension > findExtension(const std::string &identifier)
Retrieve the extension having the specified identifier.
#define OSLM_TRACE(message)
FWRUNTIME_API std::vector< std::shared_ptr< ::fwRuntime::Extension > > getAllExtensionsForPoint(std::string extension_pt)
Returns extensions extending the _extension_pt extension point.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
FWRUNTIME_API std::shared_ptr< ExtensionPoint > findExtensionPoint(const std::string &identifier)
Retrieves the extension point having the specified identifier.
FWRUNTIME_API void addBundles(const boost::filesystem::path &directory)
Loads all bundles that can be found in the specified directory.
FWRUNTIME_API void startBundle(const std::string &identifier)
Starts the bundle specified by the given identifier.
FWRUNTIME_API std::shared_ptr< ::fwRuntime::profile::Profile > startProfile(const boost::filesystem::path &path)
Starts the given bundle set profile.
FWRUNTIME_API std::shared_ptr< Bundle > findBundle(const std::string &identifier, const Version &version=Version())
Retrieves the bundle with the given identifier and version.
T * createExecutableInstance(const std::shared_ptr< Extension > extension, const std::string &element="executable", const std::string &attribute="class")
Creates an executable instance for the specified configuration element.
FWRUNTIME_API::boost::filesystem::path getBundleResourceFilePath(const std::string &bundleIdentifier, const ::boost::filesystem::path &path) noexcept
Retrieve a filesystem valid path for a path relative to the bundle having the specified identifier...
FWRUNTIME_API::boost::filesystem::path getBundleResourcePath(const std::string &bundleIdentifier) noexcept
Retrieve the filesystem valid path of resources of a bundle.
Defines the generic configuration element container class.
void getAllConfigurationElementsForPoint(const std::string &identifier, OutputIterator output)
Retrieves all configuration elements for the point having the specified identifier.
Holds version information for libraries and bundles.
FWRUNTIME_API Iterator end()
Retrieves the iterator on the end of the configuration element container.
#define OSLM_DEBUG(message)