7 #include "fwRuntime/profile/Profile.hpp" 9 #include "fwRuntime/Bundle.hpp" 10 #include "fwRuntime/Extension.hpp" 11 #include "fwRuntime/profile/Activater.hpp" 12 #include "fwRuntime/profile/Initializer.hpp" 13 #include "fwRuntime/profile/Starter.hpp" 14 #include "fwRuntime/profile/Stopper.hpp" 15 #include "fwRuntime/profile/Uninitializer.hpp" 16 #include "fwRuntime/Runtime.hpp" 30 template<
typename E >
35 void operator() ( E e )
44 Profile::wptr current_profile;
50 current_profile = prof;
57 return current_profile.lock();
63 m_checkSingleInstance(false),
70 m_run = std::bind(&Profile::defaultRun,
this);
87 m_activaters.push_back( activater );
94 m_starters.push_back( starter );
101 m_stoppers.push_back( stopper );
108 m_initializers.push_back(initializer);
115 m_uninitializers.push_back(uninitializer);
122 std::for_each( m_activaters.begin(), m_activaters.end(), Apply< ActivaterContainer::value_type >() );
130 "Validation not ok for bundle = '" << extension->getBundle()->getIdentifier() <<
"' (extension id = '" << extension->getIdentifier() <<
"' )",
134 std::for_each( m_starters.begin(), m_starters.end(), Apply< StarterContainer::value_type >() );
135 OSLM_TRACE(
"NB INITIALIZERS: " << m_initializers.size() );
142 SLM_ASSERT(
"the 'run' callback is missing", m_run);
150 int Profile::defaultRun()
160 void Profile::setRunCallback(RunCallbackType callback)
169 std::for_each( m_stoppers.rbegin(), m_stoppers.rend(), Apply< StopperContainer::value_type >() );
176 InitializerContainer initializers;
177 initializers = m_initializers;
178 m_initializers.clear();
179 std::for_each( initializers.begin(), initializers.end(), Apply< InitializerContainer::value_type >() );
184 void Profile::cleanup()
186 std::for_each( m_uninitializers.rbegin(), m_uninitializers.rend(), Apply< UninitializerContainer::value_type >() );
187 m_uninitializers.clear();
192 void Profile::setParams(
int argc,
char** argv)
194 ParamsContainer params;
195 for(
int i = 0; i < argc; ++i)
197 params.push_back( std::string(argv[i]) );
199 this->setParams(params);
204 void Profile::setParams(
const Profile::ParamsContainer& params)
213 m_argc =
static_cast<int>(m_params.size());
215 m_argv =
new char*[m_params.size()];
218 for(
size_t i = 0; i < m_params.size(); i++)
220 size_t paramSize = m_params[i].size();
221 m_argv[i] =
new char[paramSize+1];
223 strncpy(m_argv[i], m_params[i].c_str(), paramSize);
224 m_argv[i][paramSize] =
'\0';
226 strncpy_s(m_argv[i], paramSize+1, m_params[i].c_str(), paramSize);
static FWRUNTIME_API Runtime * getDefault()
Retrieves the default runtime instance.
Defines the runtime class.
ExtensionContainer::iterator ExtensionIterator
Defines the extension container type.
FWRUNTIME_API void add(std::shared_ptr< Activater > activater)
Adds a new activator.
FWRUNTIME_API void setCurrentProfile(Profile::sptr prof)
Set current profile.
Activates a given bundle with optional parameters.
Defines the extension class.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
FWRUNTIME_API ExtensionIterator extensionsEnd()
Retrieves the iterator on the end of the extension collection.
FWRUNTIME_API Profile::sptr getCurrentProfile()
Get current profile.
FWRUNTIME_API ExtensionIterator extensionsBegin()
Retrieves the iterator on the beginning of the extension collection.
#define OSLM_TRACE(message)
FWRUNTIME_API void setup()
Once started, setup the profile.
The extension failed the validation.
FWRUNTIME_API int run()
Run the profile.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWRUNTIME_API void start()
Starts the profile.
FWRUNTIME_API Profile()
Constructor : does nothing.
#define OSLM_FATAL_IF(message, cond)