--- /dev/null
+#ifndef __DALI_INTERNAL_BASE_TRIGGER_EVENT_FACTORY_INTERFACE_H__
+#define __DALI_INTERNAL_BASE_TRIGGER_EVENT_FACTORY_INTERFACE_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// INTERNAL INCLUDES
+#include <base/interfaces/trigger-event-interface.h>
+
+// EXTERNAL INCLUDES
+#include <boost/function.hpp>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * @brief Trigger interface factory class for creating a TriggerEvents
+ *
+ */
+class TriggerEventFactoryInterface
+{
+public:
+
+
+ /**
+ * @brief Create a new concrete implementation of the event trigger interface.
+ * @param functor the function to call when interface->Trigger() is called
+ * @return pointer to a new trigger event
+ */
+ virtual TriggerEventInterface* CreateTriggerEvent( boost::function<void()> functor,
+ TriggerEventInterface::Options options = TriggerEventInterface::NONE) = 0;
+ /**
+ * @brief destroy a trigger event
+ * @param trigger event to destroy
+ */
+ virtual void DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface ) = 0;
+
+protected:
+
+ /**
+ * @brief Constructor
+ */
+ TriggerEventFactoryInterface()
+ {
+ }
+
+ /**
+ * @brief Virtual Destructor
+ */
+ virtual ~TriggerEventFactoryInterface()
+ {
+ }
+
+private:
+
+
+ // Undefined copy constructor.
+ TriggerEventFactoryInterface( const TriggerEventFactoryInterface& );
+
+ // Undefined assignment operator.
+ TriggerEventFactoryInterface& operator=( const TriggerEventFactoryInterface& );
+
+};
+
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_BASE_TRIGGER_EVENT_FACTORY_INTERFACE_H__
{
/**
- * Interface for a trigger event class
+ * @brief Interface for a trigger event class.
+ *
+ * The trigger event is a way of running a function call back on the main event thread of Dali.
+ * To create a trigger event use the factory interface.
*/
class TriggerEventInterface
{
public:
/**
- * Triggers the event.
+ * @brief trigger event options
+ */
+ enum Options
+ {
+ NONE,
+ DELETE_AFTER_TRIGGER, // automatically delete the trigger event object, after Trigger() is called.
+ };
+
+ /**
+ * @brief Triggers the event.
*
* This can be called from one thread in order to wake up another thread.
*/
protected:
/**
- * Constructor
+ * @brief Constructor
*/
- TriggerEventInterface()
+ TriggerEventInterface( )
{
}
/**
- * Virtual protected destructor, no deletion through this interface
+ * @brief Virtual destructor
*/
virtual ~TriggerEventInterface()
{
}
+private:
+
// Undefined copy constructor.
TriggerEventInterface( const TriggerEventInterface& );
{
return *mNotificationTrigger;
}
+TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
+{
+ return mTriggerEventFactory;
+}
RenderSurface* Adaptor::GetRenderSurfaceInterface()
{
return mSurface;
#include <internal/common/damage-observer.h>
#include <internal/common/window-visibility-observer.h>
#include <internal/common/kernel-trace.h>
+#include <internal/common/trigger-event-factory.h>
namespace Dali
{
virtual TriggerEventInterface& GetTriggerEventInterface();
/**
+ * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventFactoryInterface()
+ */
+ virtual TriggerEventFactoryInterface& GetTriggerEventFactoryInterface();
+
+ /**
* @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetRenderSurfaceInterface()
*/
virtual RenderSurface* GetRenderSurfaceInterface();
DeviceLayout mBaseLayout; ///< The base layout of the application
LogOptions mLogOptions; ///< log options
PerformanceInterface* mPerformanceInterface; ///< Performance interface
- KernelTrace mKernelTracer;
+ KernelTrace mKernelTracer; ///< Kernel tracer
+ TriggerEventFactory mTriggerEventFactory; ///< Trigger event factory
public:
inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;}
};
$(tizen_adaptor_internal_src_dir)/tilt-sensor-impl.cpp \
$(tizen_adaptor_internal_src_dir)/timer-impl.cpp \
$(tizen_adaptor_internal_src_dir)/trigger-event.cpp \
+ $(tizen_adaptor_internal_src_dir)/trigger-event-factory.cpp \
$(tizen_adaptor_internal_src_dir)/tts-player-impl.cpp \
$(tizen_adaptor_internal_src_dir)/virtual-keyboard-impl.cpp \
$(tizen_adaptor_internal_src_dir)/vsync-monitor.cpp \
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// CLASS HEADER
+#include "trigger-event-factory.h"
+
+// INTERNAL INCLUDES
+#include <internal/common/trigger-event.h>
+
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+TriggerEventInterface* TriggerEventFactory::CreateTriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options )
+{
+ return new TriggerEvent( functor, options );
+}
+
+void TriggerEventFactory::DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface )
+{
+ TriggerEvent* triggerEvent( static_cast< TriggerEvent* >( triggerEventInterface) );
+ delete triggerEvent;
+}
+
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
+#define __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// INTERNAL INCLUDES
+#include <base/interfaces/trigger-event-factory-interface.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+/**
+ * @brief Trigger interface factory class
+ *
+ */
+class TriggerEventFactory : public TriggerEventFactoryInterface
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ */
+ TriggerEventFactory()
+ {
+ }
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~TriggerEventFactory()
+ {
+ }
+
+ /**
+ * @copydoc TriggerEventFactoryInterface::CreateTriggerEvent
+ */
+ virtual TriggerEventInterface* CreateTriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options );
+
+
+ /**
+ * @copydoc TriggerEventFactoryInterface::DestroyTriggerEvent
+ */
+ virtual void DestroyTriggerEvent( TriggerEventInterface* triggerEventInterface );
+
+};
+
+} // namespace Internal
+
+} // namespace Adaptor
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_ADAPTOR_TRIGGER_EVENT_FACTORY_H__
namespace Adaptor
{
-TriggerEvent::TriggerEvent( boost::function<void()> functor )
+TriggerEvent::TriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options )
: mFileDescriptorMonitor(NULL),
mFunctor(functor),
- mFileDescriptor(-1)
+ mFileDescriptor(-1),
+ mOptions( options )
{
// Create accompanying file descriptor.
mFileDescriptor = eventfd(0, EFD_NONBLOCK);
// Call the connected boost function.
mFunctor();
+
+ //check if we should delete ourselves after the trigger
+ if( mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER )
+ {
+ delete this;
+ }
}
} // namespace Adaptor
* descriptor when there is data.
*
* @param[in] functor to call
+ * @param[in] options, trigger event options.
*/
- TriggerEvent( boost::function<void()> functor );
+ TriggerEvent( boost::function<void()> functor, TriggerEventInterface::Options options = TriggerEventInterface::NONE );
/**
* Destructor
FileDescriptorMonitor* mFileDescriptorMonitor;
boost::function<void()> mFunctor; ///< Function object to call
int mFileDescriptor;
+ TriggerEventInterface::Options mOptions;
};
} // namespace Adaptor