fw4spl
ExtensionPoint.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
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 #include "fwRuntime/ExtensionPoint.hpp"
8 
9 #include "fwRuntime/Bundle.hpp"
10 #include "fwRuntime/io/Validator.hpp"
11 #include "fwRuntime/RuntimeException.hpp"
12 
13 namespace fwRuntime
14 {
15 
16 //------------------------------------------------------------------------------
17 
18 ExtensionPoint::ExtensionPoint( const std::shared_ptr< Bundle > bundle, const std::string& id,
19  const ::boost::filesystem::path& schema ) :
20  BundleElement( bundle ),
21  m_id( id ),
22  m_schema( schema )
23 {
24 }
25 
26 //------------------------------------------------------------------------------
27 
28 const std::string& ExtensionPoint::getIdentifier() const
29 {
30  return m_id;
31 }
32 
33 //------------------------------------------------------------------------------
34 
35 std::shared_ptr< io::Validator > ExtensionPoint::getExtensionValidator() const
36 {
37  if( !m_schema.empty() && !m_validator )
38  {
39  try
40  {
41  const ::boost::filesystem::path schemaPath = getBundle()->getResourcesLocation() / m_schema;
42  OSLM_DEBUG( "Use this schema : " << schemaPath << " for this id : " << m_id );
43  m_validator = std::shared_ptr< io::Validator >( new io::Validator(schemaPath) );
44  }
45  catch( const std::exception& e )
46  {
47  throw RuntimeException( "Error while creating a validator. " + std::string(e.what()) );
48  }
49  }
50  return m_validator;
51 }
52 
53 //------------------------------------------------------------------------------
54 
55 void ExtensionPoint::operator=( const ExtensionPoint& ) noexcept
56 {
57 }
58 
59 //------------------------------------------------------------------------------
60 
61 } // namespace fwRuntime
Implements the base class for all element managed by a bundle.
Defines the runtime exception class.
ExtensionPoint(const std::shared_ptr< Bundle > bundle, const std::string &id, const boost::filesystem::path &schema)
constructor
Defines the extension point class.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
FWRUNTIME_API const std::string & getIdentifier() const
Retrieves the extension point identifier.
Implements an XML validator.
Definition: Validator.hpp:37
FWRUNTIME_API std::shared_ptr< io::Validator > getExtensionValidator() const
Retrieves the extension validator.
FWRUNTIME_API std::shared_ptr< Bundle > getBundle() const
Retrieves the bundle that owns the extension.
#define OSLM_DEBUG(message)
Definition: spyLog.hpp:241