1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_NODE_ATTACHMENT_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_NODE_ATTACHMENT_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/internal/common/message.h>
34 class RenderableAttachment;
35 class SceneController;
38 * NodeAttachment is a base class for objects attached to Nodes in the scene graph.
39 * The position of the object is provided by its parent node.
40 * NodeAttachment data is double-buffered. This allows an update thread to modify node data, without interferring
41 * with another thread reading the values from the previous update traversal.
50 virtual ~NodeAttachment();
53 * Second-phase construction.
54 * This is called by the UpdateManager, when the attachment is attached to the scene-graph.
55 * @param[in] sceneController Allows attachments to get light/camera controllers.
56 * @param[in] updateBufferIndex The current update buffer index.
58 virtual void ConnectToSceneGraph( SceneController& sceneController, BufferIndex updateBufferIndex ) = 0;
61 * Called shortly before destruction.
62 * After this method has been called, the SceneController cannot be safely accessed.
64 virtual void OnDestroy() = 0;
67 * Set the parent of a NodeAttachment.
68 * @param[in] parent the new parent.
70 void SetParent( Node& parent );
73 * Retrieve the parent node of a NodeAttachment.
74 * @return The parent node, or NULL if the NodeAttachment has not been added to the scene-graph.
78 DALI_ASSERT_DEBUG( mParent != NULL );
83 * Retrieve the parent node of a NodeAttachment.
84 * @return The parent node, or NULL if the NodeAttachment has not been added to the scene-graph.
86 Node& GetParent() const
88 DALI_ASSERT_DEBUG( mParent != NULL );
92 // RenderableAttachment interface
95 * Query whether the attachment is renderable i.e. implements the SceneGraph::RenderableAttachment interface.
96 * @return True if the attachment is renderable.
100 return (GetRenderable() != NULL);
104 * Convert an attachment to a renderable attachment.
105 * @return A pointer to the renderable attachment, or NULL.
107 virtual RenderableAttachment* GetRenderable() = 0;
112 * Called when the attachment or it's owning node is flagged as dirty during scene graph updates.
113 * Allows derived classes to perform extra processing
114 * @param[in] updateBufferIndex The current update buffer index.
115 * @param[in] owningNode The attachment's owning node
116 * @param[in] nodeDirtyFlags of the owning node
118 virtual void Update( BufferIndex updateBufferIndex, const Node& owningNode, int nodeDirtyFlags ) {}
123 * Derived versions of NodeAttachment should be constructed.
130 NodeAttachment( const NodeAttachment& );
133 NodeAttachment& operator=( const NodeAttachment& rhs );
137 Node* mParent; ///< Pointer to parent node which owns the attachment.
140 } // namespace SceneGraph
142 } // namespace Internal
146 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_ATTACHMENT_H__