/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-#include "layout-controller.h"
+#include "processor-controller.h"
#include <dali/integration-api/adaptor-framework/adaptor.h>
#ifdef __cplusplus
extern "C" {
#endif
-namespace
-{
-static int gLayoutControllerId = 1;
-} // unnamed namespace
-
-LayoutController::LayoutController() : handler(NULL), mId( gLayoutControllerId++ )
+ProcessorController::ProcessorController()
{
Dali::Adaptor::Get().RegisterProcessor(*this);
}
-LayoutController::~LayoutController()
+ProcessorController::~ProcessorController()
{
Dali::Adaptor::Get().UnregisterProcessor(*this);
}
-
-int LayoutController::GetId() const
+void ProcessorController::Process(bool postProcessor)
{
- return mId;
+ mHandler();
}
-void LayoutController::Process(bool postProcessor)
+void ProcessorController::SetCallback( ProcessorControllerProcessCallback callback )
{
- if( handler )
- {
- handler( mId );
- }
+ mHandler = callback;
}
-void LayoutController::SetCallback( LayoutControllerProcessCallback callback )
+void ProcessorController::RemoveCallback( ProcessorControllerProcessCallback callback )
{
- handler = callback;
+ mHandler = nullptr;
}
-// LayoutController Bindings
-
-SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_LayoutController() {
+// ProcessorController Bindings
+SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_ProcessorController() {
- LayoutController *result = 0 ;
+ ProcessorController *result = 0 ;
{
try {
- result = (LayoutController *)new LayoutController();
+ result = (ProcessorController *)new ProcessorController();
} catch (std::out_of_range& e) {
{
SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
return (void *)result;
}
-SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_LayoutController(void * jarg1) {
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_ProcessorController(void * jarg1) {
- LayoutController * arg1 = (LayoutController *)jarg1;
+ ProcessorController * arg1 = (ProcessorController *)jarg1;
{
try {
delete arg1;
}
}
-SWIGEXPORT void SWIGSTDCALL CSharp_Dali_LayoutController_SetCallback( void* jarg1, LayoutController::LayoutControllerProcessCallback callback )
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_ProcessorController_SetCallback( void* jarg1, ProcessorController::ProcessorControllerProcessCallback callback )
{
- LayoutController* layoutController = (LayoutController *) jarg1;
+ ProcessorController* processorController = (ProcessorController *) jarg1;
- if( layoutController )
+ if( processorController )
{
- layoutController->SetCallback( callback );
+ processorController->SetCallback( callback );
}
}
-SWIGEXPORT int SWIGSTDCALL CSharp_Dali_LayoutController_GetId( void* jarg1 )
+SWIGEXPORT void SWIGSTDCALL CSharp_Dali_ProcessorController_RemoveCallback( void* jarg1, ProcessorController::ProcessorControllerProcessCallback callback )
{
- LayoutController * layoutController = (LayoutController *)jarg1;
- int ret = 0;
- if( layoutController )
+ ProcessorController* processorController = (ProcessorController *) jarg1;
+
+ if( processorController )
{
- ret = layoutController->GetId();
+ processorController->RemoveCallback( callback );
}
- return ret;
}
#ifdef __cplusplus
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// EXTERNAL INCLUDES
+#include <vector>
#include <dali/integration-api/processor-interface.h>
// INTERNAL INCLUDES
* a Processor. Enables the setting of a callback so dali-core can execute this callback when
* Process() is run.
*/
-class LayoutController : public Dali::Integration::Processor
+class ProcessorController : public Dali::Integration::Processor
{
public:
- // Function pointer matching delegate in C# LayoutController
- using LayoutControllerProcessCallback = void (SWIGSTDCALL*)(int);
+ // Function pointer matching delegate in C# ProcessorController
+ using ProcessorControllerProcessCallback = void (SWIGSTDCALL*)();
public:
/**
- * @brief Constructor - creates a LayoutController and registers it with dali-core.
+ * @brief Constructor - creates a ProcessorController and registers it with dali-core.
*
*/
- LayoutController();
+ ProcessorController();
/**
* @brief Destructor - Unregisters itself from dali-core.
*/
- ~LayoutController();
-
- /**
- * @brief Gets the id of the LayoutController that was initialised during construction.
- * @return the id of the LayoutController.
- * @note Useful for debugging when multiple LayoutControllers are registered with dali-core.
- */
- int GetId() const;
+ ~ProcessorController();
/**
* @copydoc Dali::Integration::Processor::Process()
* @brief Set the callback to be executed when dali-core calls the overriden Process() api.
* @param[in] callback, function to be called
*/
- void SetCallback( LayoutControllerProcessCallback callback );
-
-private:
+ void SetCallback( ProcessorControllerProcessCallback callback );
- LayoutControllerProcessCallback handler;
+ /**
+ * @brief Remove callback on this ProcessorController.
+ * The removed callback will not be called anymore.
+ * @param[in] callback, function will be removed
+ */
+ void RemoveCallback( ProcessorControllerProcessCallback callback );
- int mId;
+private:
+ ProcessorControllerProcessCallback mHandler;
};
\ No newline at end of file