Add OffscreenApplication
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.h
1 #ifndef DALI_INTERNAL_ADAPTOR_IMPL_H
2 #define DALI_INTERNAL_ADAPTOR_IMPL_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/math/rect.h>
24 #include <dali/public-api/signals/callback.h>
25 #include <dali/public-api/math/uint-16-pair.h>
26 #include <dali/integration-api/render-controller.h>
27
28 // INTERNAL INCLUDES
29 #include <dali/public-api/adaptor-framework/tts-player.h>
30 #include <dali/devel-api/adaptor-framework/clipboard.h>
31 #include <dali/integration-api/scene.h>
32 #include <dali/integration-api/adaptor-framework/adaptor.h>
33 #include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
34 #include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
35 #include <dali/internal/adaptor/common/adaptor-internal-services.h>
36 #include <dali/internal/graphics/common/graphics-interface.h>
37 #include <dali/internal/legacy/common/tizen-platform-abstraction.h>
38 #include <dali/internal/network/common/socket-factory.h>
39 #include <dali/internal/system/common/core-event-interface.h>
40 #include <dali/internal/system/common/environment-options.h>
41 #include <dali/internal/system/common/kernel-trace.h>
42 #include <dali/internal/system/common/system-trace.h>
43 #include <dali/internal/window-system/common/damage-observer.h>
44 #include <dali/internal/window-system/common/window-visibility-observer.h>
45
46 namespace Dali
47 {
48
49 class RenderSurfaceInterface;
50
51 namespace Integration
52 {
53 class Core;
54 class GlAbstraction;
55 class Processor;
56 class AddOnManager;
57 }
58
59 namespace Internal
60 {
61
62 namespace Adaptor
63 {
64 class DisplayConnection;
65 class GraphicsFactory;
66 class GlImplementation;
67 class GlSyncImplementation;
68 class ThreadController;
69 class TriggerEvent;
70 class CallbackManager;
71 class FeedbackPluginProxy;
72 class FeedbackController;
73 class VSyncMonitor;
74 class PerformanceInterface;
75 class LifeCycleObserver;
76 class ObjectProfiler;
77 class SceneHolder;
78 class ConfigurationManager;
79 enum class ThreadMode;
80
81 /**
82  * Implementation of the Adaptor class.
83  */
84 class Adaptor : public Integration::RenderController,
85                 public AdaptorInternalServices,
86                 public CoreEventInterface,
87                 public DamageObserver,
88                 public WindowVisibilityObserver
89 {
90 public:
91
92   using AdaptorSignalType =  Dali::Adaptor::AdaptorSignalType;
93   using WindowCreatedSignalType = Dali::Adaptor::WindowCreatedSignalType;
94
95   using SurfaceSize = Uint16Pair;          ///< Surface size type
96
97   /**
98    * Creates a New Adaptor
99    * @param[in]  window              The window handle
100    * @param[in]  surface             A render surface can be one of the following
101    *                                  - Pixmap, adaptor will use existing Pixmap to draw on to
102    *                                  - Window, adaptor will use existing Window to draw on to
103    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
104    * @param[in]  threadMode          The thread mode
105    */
106   static Dali::Adaptor* New( Dali::Integration::SceneHolder window,
107                              Dali::RenderSurfaceInterface* surface,
108                              EnvironmentOptions* environmentOptions,
109                              ThreadMode threadMode );
110
111   /**
112    * Creates a New Adaptor
113    * @param[in]  window              The window handle
114    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
115    */
116   static Dali::Adaptor* New( Dali::Integration::SceneHolder window,
117                              EnvironmentOptions* environmentOptions );
118
119   /**
120    * Creates a New Adaptor
121    * @param[in]  graphicsFactory     A factory that creates the graphics interface
122    * @param[in]  window              The window handle
123    * @param[in]  surface             A render surface can be one of the following
124    *                                  - Pixmap, adaptor will use existing Pixmap to draw on to
125    *                                  - Window, adaptor will use existing Window to draw on to
126    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
127    * @param[in]  threadMode          The thread mode
128    */
129   static Dali::Adaptor* New( GraphicsFactory& graphicsFactory,
130                              Dali::Integration::SceneHolder window,
131                              Dali::RenderSurfaceInterface* surface,
132                              EnvironmentOptions* environmentOptions,
133                              ThreadMode threadMode );
134
135   /**
136    * Creates a New Adaptor
137    * @param[in]  graphicsFactory     A factory that creates the graphics interface
138    * @param[in]  window              The window handle
139    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
140    */
141   static Dali::Adaptor* New( GraphicsFactory& graphicsFactory,
142                              Dali::Integration::SceneHolder window,
143                              EnvironmentOptions* environmentOptions );
144
145   /**
146    * 2-step initialisation, this should be called after creating an adaptor instance.
147    * @param[in]  graphicsFactory     A factory that creates the graphics interface
148    */
149   void Initialize( GraphicsFactory& graphicsFactory );
150
151   /**
152    * Virtual destructor.
153    */
154   ~Adaptor() override;
155
156   /**
157    * @copydoc Dali::Adaptor::Get()
158    */
159   static Dali::Adaptor& Get();
160
161   /**
162    * @copydoc Dali::Adaptor::IsAvailable()
163    */
164   static bool IsAvailable();
165
166   /**
167    * @copydoc Dali::Core::SceneCreated();
168    */
169   void SceneCreated();
170
171 public: // AdaptorInternalServices implementation
172   /**
173    * @copydoc Dali::Adaptor::Start()
174    */
175   virtual void Start();
176
177   /**
178    * @copydoc Dali::Adaptor::Pause()
179    */
180   virtual void Pause();
181
182   /**
183    * @copydoc Dali::Adaptor::Resume()
184    */
185   virtual void Resume();
186
187   /**
188    * @copydoc Dali::Adaptor::Stop()
189    */
190   virtual void Stop();
191
192   /**
193    * @copydoc Dali::Adaptor::ContextLost()
194    */
195   virtual void ContextLost();
196
197   /**
198    * @copydoc Dali::Adaptor::ContextRegained()
199    */
200   virtual void ContextRegained();
201
202   /**
203    * @copydoc Dali::EventFeeder::FeedTouchPoint()
204    */
205   virtual void FeedTouchPoint( TouchPoint& point, int timeStamp );
206
207   /**
208    * @copydoc Dali::EventFeeder::FeedWheelEvent()
209    */
210   virtual void FeedWheelEvent( Dali::WheelEvent& wheelEvent );
211
212   /**
213    * @copydoc Dali::EventFeeder::FeedKeyEvent()
214    */
215   virtual void FeedKeyEvent( Dali::KeyEvent& keyEvent );
216
217   /**
218    * @copydoc Dali::Adaptor::ReplaceSurface()
219    */
220   virtual void ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface );
221
222   /**
223    * @copydoc Dali::Adaptor::GetSurface()
224    */
225   virtual Dali::RenderSurfaceInterface& GetSurface() const;
226
227   /**
228    * @copydoc Dali::Adaptor::ReleaseSurfaceLock()
229    */
230   virtual void ReleaseSurfaceLock();
231
232   /**
233    * Retrieve the TtsPlayer.
234    * @param[in] mode The mode of TtsPlayer
235    * @return A handle to the TtsPlayer.
236    */
237   virtual Dali::TtsPlayer GetTtsPlayer(Dali::TtsPlayer::Mode mode);
238
239   /**
240    * @copydoc Dali::Adaptor::AddIdle()
241    */
242   virtual bool AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd );
243
244   /**
245    * Adds a new Window instance to the Adaptor
246    * @param[in]  childWindow The child window instance
247    */
248   virtual bool AddWindow( Dali::Integration::SceneHolder childWindow );
249
250   /**
251    * Removes an existing Window instance from the Adaptor
252    * @param[in]  window The Window instance
253    */
254   virtual bool RemoveWindow( Dali::Integration::SceneHolder* childWindow );
255
256   /**
257    * Removes an existing Window instance from the Adaptor
258    * @param[in]  windowName The Window name
259    * @note If two Windows have the same name, the first one that matches will be removed
260    */
261   virtual bool RemoveWindow( std::string childWindowName );
262
263   /**
264    * @copydoc Dali::Adaptor::RemoveIdle()
265    */
266   virtual void RemoveIdle( CallbackBase* callback );
267
268   /**
269    * @copydoc Dali::Adaptor::ProcessIdle()
270    */
271   virtual void ProcessIdle();
272
273   /**
274    * Sets a pre-render callback.
275    */
276   void SetPreRenderCallback( CallbackBase* callback );
277
278   /**
279    * Removes an existing Window instance from the Adaptor
280    * @param[in]  childWindow The Window instance
281    */
282   bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow );
283
284   /**
285    * @brief Deletes the rendering surface
286    * @param[in] surface to delete
287    */
288   void DeleteSurface( Dali::RenderSurfaceInterface& surface );
289
290   /**
291    * @brief Retrieve the window that the given actor is added to.
292    *
293    * @param[in] actor The actor
294    * @return The window the actor is added to or a null pointer if the actor is not added to any widnow.
295    */
296   Dali::Internal::Adaptor::SceneHolder* GetWindow( Dali::Actor& actor );
297
298   /**
299    * @copydoc Dali::Adaptor::GetWindows()
300    */
301   Dali::WindowContainer GetWindows() const;
302
303   /**
304    * @copydoc Dali::Adaptor::GetSceneHolders()
305    */
306   Dali::SceneHolderList GetSceneHolders() const;
307
308   /**
309    * @copydoc Dali::Adaptor::GetObjectRegistry()
310    */
311   Dali::ObjectRegistry GetObjectRegistry() const;
312
313 public:
314
315   /**
316    * @return the Core instance
317    */
318   Dali::Integration::Core& GetCore() override;
319
320   /**
321    * @copydoc Dali::Adaptor::SetRenderRefreshRate()
322    */
323   void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender );
324
325   /**
326    * Return the PlatformAbstraction.
327    * @return The PlatformAbstraction.
328    */
329   Integration::PlatformAbstraction& GetPlatformAbstraction() const;
330
331   /**
332    * Destroy the TtsPlayer of specific mode.
333    * @param[in] mode The mode of TtsPlayer to destroy
334    */
335   void DestroyTtsPlayer(Dali::TtsPlayer::Mode mode);
336
337   /**
338    * Gets native window handle
339    *
340    * @return native window handle
341    */
342   Any GetNativeWindowHandle();
343
344   /**
345    * @brief Retrieve native window handle that the given actor is added to.
346    *
347    * @param[in] actor The actor
348    * @return native window handle
349    */
350   Any GetNativeWindowHandle( Dali::Actor actor );
351
352   /**
353    * Get the native display associated with the graphics backend
354    *
355    * @return A handle to the native display
356    */
357   Any GetGraphicsDisplay();
358
359   /**
360    * Sets use remote surface for Surface output
361    * @param[in] useRemoteSurface True if the remote surface is used
362    */
363   void SetUseRemoteSurface(bool useRemoteSurface);
364
365 public:
366
367   /**
368    * Adds an adaptor observer so that we can observe the adaptor's lifetime events.
369    * @param[in]  observer  The observer.
370    * @note Observers should remove themselves when they are destroyed.
371    */
372   void AddObserver( LifeCycleObserver& observer );
373
374   /**
375    * Removes the observer from the adaptor.
376    * @param[in]  observer  The observer to remove.
377    * @note Observers should remove themselves when they are destroyed.
378    */
379   void RemoveObserver( LifeCycleObserver& observer );
380
381   /**
382    * Emits the Notification event to the Dali core.
383    */
384   void SendNotificationEvent();
385
386   /**
387    * Request adaptor to update once
388    */
389   void RequestUpdateOnce();
390
391   /**
392    * @copydoc Dali::Adaptor::NotifySceneCreated()
393    */
394   void NotifySceneCreated();
395
396   /**
397    * @copydoc Dali::Adaptor::NotifyLanguageChanged()
398    */
399   void NotifyLanguageChanged();
400
401   /**
402    * Gets AppId of current application
403    */
404   void GetAppId( std::string& appId );
405
406   /**
407    * @copydoc Dali::Adaptor::SurfaceResizePrepare
408    */
409   void SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
410
411   /**
412    * @copydoc Dali::Adaptor::SurfaceResizeComplete
413    */
414   void SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize );
415
416   /**
417    * Sets layout direction of root by system language
418    * @param[in] locale System locale
419    */
420   void SetRootLayoutDirection( std::string locale );
421
422   /**
423    * @copydoc Dali::Adaptor::RenderOnce
424    */
425   void RenderOnce();
426
427   /**
428    * @copydoc Dali::Adaptor::GetLogFactory
429    */
430   const LogFactoryInterface& GetLogFactory();
431
432   /**
433    * @copydoc Dali::Adaptor::RegisterProcessor
434    */
435   void RegisterProcessor( Integration::Processor& processor );
436
437   /**
438    * @coydoc Dali::Adaptor::UnregisterProcessor
439    */
440   void UnregisterProcessor( Integration::Processor& processor );
441
442   /**
443    * Check MultipleWindow is supported
444    */
445   bool IsMultipleWindowSupported() const;
446
447 public:  //AdaptorInternalServices
448
449   /**
450    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPlatformAbstractionInterface()
451    */
452   Dali::Integration::PlatformAbstraction& GetPlatformAbstractionInterface() override;
453
454   /**
455    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetDisplayConnectionInterface()
456    */
457   Dali::DisplayConnection& GetDisplayConnectionInterface() override;
458
459   /**
460    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetGraphicsInterface()
461    */
462   GraphicsInterface& GetGraphicsInterface() override;
463
464   /**
465    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface()
466    */
467   TriggerEventInterface& GetProcessCoreEventsTrigger() override;
468
469   /**
470    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetSocketFactoryInterface()
471    */
472   SocketFactoryInterface& GetSocketFactoryInterface() override;
473
474   /**
475    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetRenderSurfaceInterface()
476    */
477   Dali::RenderSurfaceInterface* GetRenderSurfaceInterface() override;
478
479   /**
480    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetPerformanceInterface()
481    */
482   PerformanceInterface* GetPerformanceInterface() override;
483
484   /**
485    * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetKernelTraceInterface()
486    */
487   TraceInterface& GetKernelTraceInterface() override;
488
489   /**
490    * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetSystemTraceInterface()
491    */
492   TraceInterface& GetSystemTraceInterface() override;
493
494   /**
495    * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetWindowContainerInterface()
496    */
497   void GetWindowContainerInterface( WindowContainer& windows ) override;
498
499 public: // Signals
500
501   /**
502    * @copydoc Dali::Adaptor::SignalResized
503    */
504   AdaptorSignalType& ResizedSignal()
505   {
506     return mResizedSignal;
507   }
508
509   /**
510    * @copydoc Dali::Adaptor::LanguageChangedSignal
511    */
512   AdaptorSignalType& LanguageChangedSignal()
513   {
514     return mLanguageChangedSignal;
515   }
516
517   /**
518    * @copydoc Dali::Adaptor::WindowCreatedSignal
519    */
520   WindowCreatedSignalType& WindowCreatedSignal()
521   {
522     return mWindowCreatedSignal;
523   }
524
525 public: // From Dali::Internal::Adaptor::CoreEventInterface
526
527   /**
528    * @copydoc Dali::Internal::Adaptor:CoreEventInterface:::ProcessCoreEvents()
529    */
530   void ProcessCoreEvents() override;
531
532 private: // From Dali::Internal::Adaptor::CoreEventInterface
533
534   /**
535    * @copydoc Dali::Internal::Adaptor::CoreEventInterface::QueueCoreEvent()
536    */
537   void QueueCoreEvent(const Dali::Integration::Event& event) override;
538
539 private: // From Dali::Integration::RenderController
540
541   /**
542    * @copydoc Dali::Integration::RenderController::RequestUpdate()
543    */
544   void RequestUpdate( bool forceUpdate ) override;
545
546   /**
547    * @copydoc Dali::Integration::RenderController::RequestProcessEventsOnIdle()
548    */
549   void RequestProcessEventsOnIdle( bool forceProcess ) override;
550
551 public: // From Dali::Internal::Adaptor::WindowVisibilityObserver
552
553   /**
554    * Called when the window becomes fully or partially visible.
555    */
556   void OnWindowShown() override;
557
558   /**
559    * Called when the window is fully hidden.
560    */
561   void OnWindowHidden() override;
562
563 private: // From Dali::Internal::Adaptor::DamageObserver
564
565   /**
566    * @copydoc Dali::Internal::Adaptor::DamageObserver::OnDamaged()
567    */
568   void OnDamaged( const DamageArea& area ) override;
569
570 private:
571
572   // Undefined
573   Adaptor(const Adaptor&) = delete;
574   Adaptor& operator=(Adaptor&) = delete;
575
576 private:
577
578   /**
579    * Assigns the render surface to the adaptor
580    *
581    */
582   void SetSurface(Dali::RenderSurfaceInterface *surface);
583
584   /**
585    * called after surface is created
586    */
587   void SurfaceInitialized();
588
589   /**
590    * Sends an notification message from main loop idle handler
591    */
592   bool ProcessCoreEventsFromIdle();
593
594   /**
595    * Gets path for data/resource storage.
596    * @param[out] path Path for data/resource storage
597    */
598   void GetDataStoragePath(std::string& path);
599
600   /**
601    * Sets up system information if needs
602    */
603   void SetupSystemInformation();
604
605   /**
606    * Adds a callback to be run when entering an idle state.
607    *
608    * A callback of the following type should be used:
609    * @code
610    *   bool MyFunction();
611    * @endcode
612    * This callback will be called repeatedly as long as it returns true. A return of 0 deletes this callback.
613    */
614   bool AddIdleEnterer( CallbackBase* callback, bool forceAdd );
615
616   /**
617    * Removes a previously added the idle enterer callback.
618    */
619   void RemoveIdleEnterer( CallbackBase* callback );
620
621 private:
622
623   /**
624    * Constructor
625    * @param[in]  window       window handle
626    * @param[in]  adaptor      The public adaptor
627    * @param[in]  surface      A render surface can be one of the following
628    *                          - Pixmap, adaptor will use existing Pixmap to draw on to
629    *                          - Window, adaptor will use existing Window to draw on to
630    * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
631    * @param[in]  threadMode   The ThreadMode of the Adaptor
632    */
633   Adaptor( Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions, ThreadMode threadMode );
634
635 private: // Types
636
637   enum State
638   {
639     READY,                     ///< Initial state before Adaptor::Start is called.
640     RUNNING,                   ///< Adaptor is running.
641     PAUSED,                    ///< Adaptor has been paused.
642     PAUSED_WHILE_HIDDEN,       ///< Adaptor is paused while window is hidden (& cannot be resumed until window is shown).
643     PAUSED_WHILE_INITIALIZING, ///< Adaptor is paused while application is initializing.
644     STOPPED,                   ///< Adaptor has been stopped.
645   };
646
647   // There is no weak handle for BaseHandle in DALi, but we can't ref count the window here,
648   // so we have to store the raw pointer.
649   using WindowContainer = std::vector<Dali::Internal::Adaptor::SceneHolder*>;
650   using ObserverContainer = std::vector<LifeCycleObserver*>;
651
652 private: // Data
653
654   AdaptorSignalType                     mResizedSignal;               ///< Resized signal.
655   AdaptorSignalType                     mLanguageChangedSignal;       ///< Language changed signal.
656   WindowCreatedSignalType               mWindowCreatedSignal;    ///< Window created signal.
657
658   Dali::Adaptor&                        mAdaptor;                     ///< Reference to public adaptor instance.
659   State                                 mState;                       ///< Current state of the adaptor
660   Dali::Integration::Core*              mCore;                        ///< Dali Core
661   ThreadController*                     mThreadController;            ///< Controls the threads
662
663   std::unique_ptr< GraphicsInterface >  mGraphics;                    ///< Graphics interface
664   Dali::DisplayConnection*              mDisplayConnection;           ///< Display connection
665   WindowContainer                       mWindows;                     ///< A container of all the Windows that are currently created
666
667   std::unique_ptr<ConfigurationManager> mConfigurationManager;        ///< Configuration manager
668
669   TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction;      ///< Platform abstraction
670
671   CallbackManager*                      mCallbackManager;             ///< Used to install callbacks
672   bool                                  mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
673   TriggerEventInterface*                mNotificationTrigger;         ///< Notification event trigger
674   FeedbackPluginProxy*                  mDaliFeedbackPlugin;          ///< Used to access feedback support
675   FeedbackController*                   mFeedbackController;          ///< Plays feedback effects for Dali-Toolkit UI Controls.
676   Dali::TtsPlayer                       mTtsPlayers[Dali::TtsPlayer::MODE_NUM];                   ///< Provides TTS support
677   ObserverContainer                     mObservers;                   ///< A list of adaptor observer pointers
678   EnvironmentOptions*                   mEnvironmentOptions;          ///< environment options
679   PerformanceInterface*                 mPerformanceInterface;        ///< Performance interface
680   KernelTrace                           mKernelTracer;                ///< Kernel tracer
681   SystemTrace                           mSystemTracer;                ///< System tracer
682   ObjectProfiler*                       mObjectProfiler;              ///< Tracks object lifetime for profiling
683   SocketFactory                         mSocketFactory;               ///< Socket factory
684   ThreadMode                            mThreadMode;                  ///< The thread mode
685   const bool                            mEnvironmentOptionsOwned:1;   ///< Whether we own the EnvironmentOptions (and thus, need to delete it)
686   bool                                  mUseRemoteSurface:1;          ///< whether the remoteSurface is used or not
687   Dali::LayoutDirection::Type           mRootLayoutDirection;         ///< LayoutDirection of window
688
689   std::unique_ptr<Integration::AddOnManager> mAddOnManager;           ///< Pointer to the addon manager
690
691 public:
692   inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) { return *adaptor.mImpl; }
693 };
694
695 } // namespace Internal
696
697 } // namespace Adaptor
698
699 } // namespace Dali
700
701 #endif // DALI_INTERNAL_ADAPTOR_IMPL_H