Add pepper-dali
[platform/core/uifw/pepper-dali.git] / pepper-dali / internal / shell-impl.h
1 #ifndef __DALI_PEPPER_INTERNAL_SHELL_H__
2 #define __DALI_PEPPER_INTERNAL_SHELL_H__
3
4 /*
5  * Copyright (c) 2016 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 // INTERNAL INCLUDES
22 #include <pepper-dali/internal/shell.h>
23 #include <pepper-dali/internal/shell-client.h>
24
25 // EXTERNAL INCLUDES
26 #include <dali/public-api/common/intrusive-ptr.h>
27 #include <dali/public-api/object/base-object.h>
28 #include <wayland-server.h>
29
30 namespace Dali
31 {
32
33 namespace Pepper
34 {
35
36 namespace Internal
37 {
38
39 class Shell;
40 typedef IntrusivePtr<Shell> ShellPtr;
41
42 struct ShellClientInfo
43 {
44   ShellPtr mShell;
45   Pepper::ShellClient mShellClient;
46   struct wl_listener mDestroyListner;
47 };
48
49 class Shell : public BaseObject
50 {
51 public:
52
53   static ShellPtr New( Pepper::Compositor compositor );
54
55   void OnClientDestroyed( Pepper::ShellClient shellClient );
56
57 private:
58
59   /**
60    * Construct a new Shell.
61    */
62   Shell();
63
64   /**
65    * A reference counted object may only be deleted by calling Unreference()
66    */
67   virtual ~Shell();
68
69   /**
70    * Second-phase constructor. Must be called immediately after creating a new Shell;
71    */
72   void Initialize( Pepper::Compositor& compositor );
73
74   static void OnBind( struct wl_client* client, void* data, uint32_t version, uint32_t id );
75
76 private:
77
78   // Undefined
79   Shell( const Shell& );
80
81   // Undefined
82   Shell& operator=( const Shell& rhs );
83
84 private: // Data
85
86   Pepper::Compositor mCompositor;
87
88   std::vector<Pepper::ShellClient> mShellClientList;
89 };
90
91 } // namespace Internal
92
93 // Helpers for public-api forwarding methods
94
95 inline Pepper::Internal::Shell& GetImplementation( Pepper::Shell& shell )
96 {
97   DALI_ASSERT_ALWAYS( shell && "Shell handle is empty" );
98
99   BaseObject& handle = shell.GetBaseObject();
100
101   return static_cast< Internal::Shell& >( handle );
102 }
103
104 inline const Pepper::Internal::Shell& GetImplementation( const Pepper::Shell& shell )
105 {
106   DALI_ASSERT_ALWAYS( shell && "Shell handle is empty" );
107
108   const BaseObject& handle = shell.GetBaseObject();
109
110   return static_cast< const Internal::Shell& >( handle );
111 }
112
113 } // namespace Pepper
114
115 } // namespace Dali
116
117 #endif // __DALI_PEPPER_INTERNAL_SHELL_H__