5#ifndef CCF_COMMON_RECIPE_BASE_HPP_H_
6#define CCF_COMMON_RECIPE_BASE_HPP_H_
9#include <ifw/odp/clipm/clipm.h>
21 template <
class SRC_IM_TYPE,
class TRG_IM_TYPE>
24 TRG_IM_TYPE** target_buf,
25 uint32_t* target_buf_size) {
26 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
27 *target_buf_size = (pixels *
sizeof(TRG_IM_TYPE));
28 *target_buf =
static_cast<TRG_IM_TYPE*
>(malloc(*target_buf_size));
30 SRC_IM_TYPE* im_ptr = image_buffer;
31 TRG_IM_TYPE* target_buf_ptr = *target_buf;
32 for (uint32_t n = 0; n < pixels; n++) {
33 *target_buf_ptr++ =
static_cast<TRG_IM_TYPE
>(*im_ptr++);
42 ifw::fnd::datatype::DataType* target_data_type,
43 uint32_t* target_buffer_size);
51 static const std::string&
GenId(
const std::string& proc_thread_name,
52 const std::string& recipe_name);
57 LOG4CPLUS_TRACE_METHOD(
Logger(), __PRETTY_FUNCTION__);
59 if (recipe_factory_obj.GetClassName() ==
"") {
60 CCFTHROW(
"Must define a classname for a Processing Recipe Plug-In");
63 BEGIN_CRIT_SEC(
"ifw::ccf::common::RecipeBase") {
64 if (s_recipe_factory_objects.find(recipe_factory_obj.GetClassName()) !=
65 s_recipe_factory_objects.end()) {
66 CCFTHROW(fmt::format(
"Factory object with classname: {} already exists",
67 recipe_factory_obj.GetClassName()));
69 LOG4CPLUS_INFO(
Logger(),
"Registering Processing Recipe factory object. Classname: " <<
70 recipe_factory_obj.GetClassName());
71 s_recipe_factory_objects[recipe_factory_obj.GetClassName()] = std::make_shared<TYPE>();
85 const std::string& proc_thread_name,
86 const std::string& recipe_name,
87 std::shared_ptr<RecipeBase>& new_obj);
94 const std::string& proc_thread_name,
95 std::shared_ptr<RecipeBase>& recipe_obj,
96 const bool initialise =
true);
99 static const std::map<std::string, std::shared_ptr<RecipeBase>>&
GetRecipeObjs();
103 const std::string& proc_thread_name,
104 std::shared_ptr<RecipeBase>& recipe_obj);
116 RecipeBase(
const std::string& proc_thread_name,
117 const std::string& recipe_name);
170 const std::string& recipe_name,
171 std::shared_ptr<RecipeBase>& new_object);
199 static std::map<std::string, std::shared_ptr<RecipeBase>> s_recipe_factory_objects;
200 static std::map<std::string, std::shared_ptr<RecipeBase>> s_recipe_objects;
201 static bool s_cpl_initialised;
207 std::string m_recipe_id;
208 std::string m_recipe_name;
209 std::string m_proc_thread_name;
213 std::string m_db_base_name;
#define CCFTHROW(msg)
Definition base.hpp:366
Class to be used as parent all CCF classes.
Definition base.hpp:120
Frame class used to store the data and metadata for one frames received from the camera.
Definition dataFrame.hpp:18
Processing Recipe base class. All recipes shall be derived from this class.
Definition recipeBase.hpp:47
const std::string & GetRecipeId() const
Get the ID of the recipe.
Definition recipeBase.cpp:136
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:51
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:231
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:15
void Process(DataFrame &frame)
Execute the processing of the given frame.
Definition recipeBase.cpp:206
void Initialise()
Initalise the object. Invoked after creating a new object from the factory object.
Definition recipeBase.cpp:146
void DisableRecipe()
Disable the recipe so that it will not be invoked.
Definition recipeBase.cpp:195
bool GetEnabled() const
Return the enabled status of the recipe.
Definition recipeBase.cpp:201
void Disable()
Definition recipeBase.cpp:255
static void AddRecipeFactoryObj(TYPE &recipe_factory_obj)
Static method to register a Data Publisher factory object in the internal registry.
Definition recipeBase.hpp:56
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:75
static const std::map< std::string, std::shared_ptr< RecipeBase > > & GetRecipeObjs()
Get reference to all Processing Recipe objects registered.
Definition recipeBase.cpp:95
void SetEnabled(const bool enabled)
Set the enabled status flag of the recipe object.
Definition recipeBase.cpp:189
void Enable()
Enable the recipe so that it will be invoked by the Processing Thread to which it belongs.
Definition recipeBase.cpp:238
static const std::map< std::string, std::shared_ptr< RecipeBase > > & GetRecipeFactoryObjs()
Statis method to retrieve references to the Recipe Factory Objects.
Definition recipeBase.cpp:27
const std::string & GetDbPath() const
Generate DB path for this recipe.
Definition recipeBase.cpp:172
bool GetInitialised() const
Return flag indicating if the recipe object has been initialised.
Definition recipeBase.cpp:177
const std::string & GetRecipeName() const
Get the name of the recipe.
Definition recipeBase.cpp:141
void SetStatus(const ProcStatus status)
Update status for a given Publisher Thread in the OLDB.
Definition recipeBase.cpp:269
virtual void InitialiseUser()
Initialise the recipe object. See "Initialise()".
Definition recipeBase.cpp:182
ProcStatus GetStatus() const
Get status of the recipe object.
Definition recipeBase.cpp:281
const std::string & GetProcThreadName() const
Get the name of the Processing Thread, hosting the Recipe instance.
Definition recipeBase.cpp:226
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:32
virtual void DisableUser()
Definition recipeBase.cpp:264
virtual ~RecipeBase()
Definition recipeBase.cpp:132
virtual void EnableUser()
Definition recipeBase.cpp:250
RecipeBase()
Definition recipeBase.cpp:119
virtual void ProcessUser(DataFrame &frame)
User specific processing.
Definition recipeBase.cpp:220
void ConvertImage(SRC_IM_TYPE *image_buffer, uint32_t pixels, TRG_IM_TYPE **target_buf, uint32_t *target_buf_size)
Definition recipeBase.hpp:22
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:286
log4cplus::Logger & Logger()
Definition base.cpp:23
ProcStatus
Possible states for a Processing Recipe defined.
Definition base.hpp:196
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:65