Merge "DALi Version 1.0.30" into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / images / image-connector.h
1 #ifndef __DALI_INTERNAL_IMAGE_CONNECTOR_H__
2 #define __DALI_INTERNAL_IMAGE_CONNECTOR_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 <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/event/images/image-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 /**
34  * Wrapper class which helps managing intrusive pointer assignments and Connect / Disconnect.
35  */
36 class ImageConnector
37 {
38
39 public:
40   /**
41    * Constructor. Takes no parameters.
42    */
43   ImageConnector();
44
45   /**
46    * Destructor.
47    */
48   ~ImageConnector();
49
50   /**
51    * Returns a smart pointer to the image
52    * @return a smart pointer to the image
53    */
54   ImagePtr Get() const;
55
56   /**
57    * Assigns image, calling Connect and Disconnect methods accordingly, taking onStage into account.
58    * @param [in] image   smart pointer to new Image
59    * @param [in] onStage whether Image is used on stage or not
60    */
61   void Set( ImagePtr image, bool onStage );
62
63   /**
64    * Manages connection reference count.
65    * Must be called from owner when connected to stage.
66    */
67   void OnStageConnect();
68
69   /**
70    * Manages connection reference count.
71    * Must be called from owner when disconnecting from stage.
72    */
73   void OnStageDisconnect();
74
75 private:
76
77   ImageConnector( const ImageConnector& ptr );                     ///< copy constructor, not defined
78   const ImageConnector& operator=( const ImageConnector& ptr );  ///< copy assignment operator, not defined
79
80   ImagePtr mImage;  ///< intrusive pointer to the Image. ImageConnector owns this.
81
82 };
83
84 } // namespace Internal
85
86 } // namespace Dali
87
88 #endif // __DALI_INTERNAL_IMAGE_CONNECTOR_H__