Merge "DALi Version 1.0.48" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / dynamics / scene-graph-dynamics-shape.h
1 #ifndef __SCENE_GRAPH_DYNAMICS_SHAPE_H__
2 #define __SCENE_GRAPH_DYNAMICS_SHAPE_H__
3
4 /*
5  * Copyright (c) 2014 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 <new>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/common/message.h>
26 #include <dali/internal/event/common/event-thread-services.h>
27 #include <dali/internal/event/dynamics/dynamics-declarations.h>
28
29 namespace Dali
30 {
31
32 namespace Integration
33 {
34
35 class DynamicsShape;
36
37 } // namespace Integration
38
39 namespace Internal
40 {
41
42 namespace SceneGraph
43 {
44
45 class DynamicsWorld;
46
47 class DynamicsShape
48 {
49 public:
50   /**
51    * Constructor.
52    */
53   DynamicsShape(DynamicsWorld& world);
54
55   /**
56    * Destructor.
57    */
58   virtual ~DynamicsShape();
59
60   /**
61    * Initialize shape, and add it to the world's shape container
62    */
63   void Initialize();
64
65   /**
66    * Remove from world's shape container
67    */
68   void Delete();
69
70   Integration::DynamicsShape* GetShape() const;
71
72 private:
73   // unimplemented copy constructor and assignment operator
74   DynamicsShape(const DynamicsShape&);
75   DynamicsShape& operator=(const DynamicsShape&);
76
77 protected:
78   Integration::DynamicsShape* mShape;
79   DynamicsWorld& mWorld;
80
81 }; // class DynamicsCubeShape
82
83 inline void DeleteShapeMessage( EventThreadServices& eventThreadServices, const DynamicsShape& shape )
84 {
85   typedef Message< DynamicsShape > LocalType;
86
87   // Reserve some memory inside the message queue
88   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
89
90   // Construct message in the message queue memory; note that delete should not be called on the return value
91   new (slot) LocalType( &shape, &DynamicsShape::Delete );
92 }
93
94 } // namespace SceneGraph
95
96 } // namespace Internal
97
98 } // namespace Dali
99
100 #endif // __SCENE_GRAPH_DYNAMICS_SHAPE_H__