7#ifndef CCF_COMMON_RECIPE_BASE_HPP_H_
8#define CCF_COMMON_RECIPE_BASE_HPP_H_
11#include <ifw/odp/clipm/clipm.h>
23 template <
class SRC_IM_TYPE,
class TRG_IM_TYPE>
26 TRG_IM_TYPE** target_buf,
27 uint32_t* target_buf_size) {
28 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
29 *target_buf_size = (pixels *
sizeof(TRG_IM_TYPE));
30 *target_buf =
static_cast<TRG_IM_TYPE*
>(malloc(*target_buf_size));
32 SRC_IM_TYPE* im_ptr = image_buffer;
33 TRG_IM_TYPE* target_buf_ptr = *target_buf;
34 for (uint32_t n = 0; n < pixels; n++) {
35 *target_buf_ptr++ =
static_cast<TRG_IM_TYPE
>(*im_ptr++);
44 ifw::fnd::datatype::DataType* target_data_type,
45 uint32_t* target_buffer_size);
53 static const std::string&
GenId(
const std::string& proc_thread_name,
54 const std::string& recipe_name);
59 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
61 if (recipe_factory_obj.GetClassName() ==
"") {
62 CCFTHROW(
"Must define a classname for a Processing Recipe Plug-In");
65 BEGIN_CRIT_SEC(
"ifw::ccf::common::RecipeBase") {
66 if (s_recipe_factory_objects.find(recipe_factory_obj.GetClassName()) !=
67 s_recipe_factory_objects.end()) {
68 CCFTHROW(fmt::format(
"Factory object with classname: {} already exists",
69 recipe_factory_obj.GetClassName()));
71 LOG4CPLUS_INFO(
Logger(),
"Registering Processing Recipe factory object. Classname: " <<
72 recipe_factory_obj.GetClassName());
73 s_recipe_factory_objects[recipe_factory_obj.GetClassName()] = std::make_shared<TYPE>();
87 const std::string& proc_thread_name,
88 const std::string& recipe_name,
89 std::shared_ptr<RecipeBase>& new_obj);
96 const std::string& proc_thread_name,
97 std::shared_ptr<RecipeBase>& recipe_obj,
98 const bool initialise =
true);
101 static const std::map<std::string, std::shared_ptr<RecipeBase>>&
GetRecipeObjs();
105 const std::string& proc_thread_name,
106 std::shared_ptr<RecipeBase>& recipe_obj);
118 RecipeBase(
const std::string& proc_thread_name,
119 const std::string& recipe_name);
172 const std::string& recipe_name,
173 std::shared_ptr<RecipeBase>& new_object);
204 static std::map<std::string, std::shared_ptr<RecipeBase>> s_recipe_factory_objects;
205 static std::map<std::string, std::shared_ptr<RecipeBase>> s_recipe_objects;
206 static bool s_cpl_initialised;
212 std::string m_recipe_id;
213 std::string m_recipe_name;
214 std::string m_proc_thread_name;
218 std::string m_db_base_name;
#define CCFTHROW(msg)
Definition base.hpp:399
Base()
Definition base.cpp:121
Frame class used to store the data and metadata for one frames received from the camera.
Definition dataFrame.hpp:20
const std::string & GetRecipeId() const
Get the ID of the recipe.
Definition recipeBase.cpp:137
static void GetRecipeObj(const std::string &class_name, const std::string &proc_thread_name, std::shared_ptr< RecipeBase > &recipe_obj, const bool initialise=true)
Definition recipeBase.cpp:52
virtual void CreateObjectUser(const std::string &proc_thread_name, const std::string &recipe_name, std::shared_ptr< RecipeBase > &new_object)
Instantiate a specific instance of the object.
Definition recipeBase.cpp:232
static const std::string & GenId(const std::string &proc_thread_name, const std::string &recipe_name)
Generate the ID for this recipe from the Processing Thread and Recipe number.
Definition recipeBase.cpp:16
void Process(DataFrame &frame)
Execute the processing of the given frame.
Definition recipeBase.cpp:207
void Initialise()
Initalise the object. Invoked after creating a new object from the factory object.
Definition recipeBase.cpp:147
void DisableRecipe()
Disable the recipe so that it will not be invoked.
Definition recipeBase.cpp:196
bool GetEnabled() const
Return the enabled status of the recipe.
Definition recipeBase.cpp:202
void Disable()
Definition recipeBase.cpp:256
static void AddRecipeFactoryObj(TYPE &recipe_factory_obj)
Static method to register a Data Publisher factory object in the internal registry.
Definition recipeBase.hpp:58
static bool HasRecipeObj(const std::string &class_name, const std::string &proc_thread_name, std::shared_ptr< RecipeBase > &recipe_obj)
Check if a Proc Recipe object is defined.
Definition recipeBase.cpp:76
static const std::map< std::string, std::shared_ptr< RecipeBase > > & GetRecipeObjs()
Get reference to all Processing Recipe objects registered.
Definition recipeBase.cpp:96
virtual void HandleSetupUser()
User-specific setup handling. Override in derived classes to perform custom reset logic.
Definition recipeBase.cpp:276
void SetEnabled(const bool enabled)
Set the enabled status flag of the recipe object.
Definition recipeBase.cpp:190
RecipeBase(const std::string &proc_thread_name, const std::string &recipe_name)
Definition recipeBase.cpp:101
void HandleSetup()
Definition recipeBase.cpp:270
void Enable()
Enable the recipe so that it will be invoked by the Processing Thread to which it belongs.
Definition recipeBase.cpp:239
static const std::map< std::string, std::shared_ptr< RecipeBase > > & GetRecipeFactoryObjs()
Statis method to retrieve references to the Recipe Factory Objects.
Definition recipeBase.cpp:28
const std::string & GetDbPath() const
Generate DB path for this recipe.
Definition recipeBase.cpp:173
bool GetInitialised() const
Return flag indicating if the recipe object has been initialised.
Definition recipeBase.cpp:178
const std::string & GetRecipeName() const
Get the name of the recipe.
Definition recipeBase.cpp:142
void SetStatus(const ProcStatus status)
Update status for a given Publisher Thread in the OLDB.
Definition recipeBase.cpp:281
virtual void InitialiseUser()
Initialise the recipe object. See "Initialise()".
Definition recipeBase.cpp:183
ProcStatus GetStatus() const
Get status of the recipe object.
Definition recipeBase.cpp:293
const std::string & GetProcThreadName() const
Get the name of the Processing Thread, hosting the Recipe instance.
Definition recipeBase.cpp:227
static void CreateRecipeObj(const std::string &class_name, const std::string &proc_thread_name, const std::string &recipe_name, std::shared_ptr< RecipeBase > &new_obj)
Definition recipeBase.cpp:33
virtual void DisableUser()
Definition recipeBase.cpp:265
virtual ~RecipeBase()
Definition recipeBase.cpp:133
virtual void EnableUser()
Definition recipeBase.cpp:251
RecipeBase()
Definition recipeBase.cpp:120
virtual void ProcessUser(DataFrame &frame)
User specific processing.
Definition recipeBase.cpp:221
Definition appBase.cpp:10
void ConvertImage(SRC_IM_TYPE *image_buffer, uint32_t pixels, TRG_IM_TYPE **target_buf, uint32_t *target_buf_size)
Definition recipeBase.hpp:24
void PrepCplImage(const ifw::ccf::common::DataFrame &frame, cpl_image **image, ifw::fnd::datatype::DataType *target_data_type, uint32_t *target_buffer_size)
Definition recipeBase.cpp:298
log4cplus::Logger & Logger()
Definition base.cpp:24
ProcStatus
Possible states for a Processing Recipe defined.
Definition base.hpp:198
void AssertPtr(const void *ptr, const std::string &object, const std::string &location)
Check that pointer is not nullptr and raise rad::exception in case it is.
Definition base.cpp:66