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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/internal/common/message.h>
33 class RenderableAttachment;
34 class SceneController;
37 * NodeAttachment is a base class for objects attached to Nodes in the scene graph.
38 * The position of the object is provided by its parent node.
39 * NodeAttachment data is double-buffered. This allows an update thread to modify node data, without interferring
40 * with another thread reading the values from the previous update traversal.
49 virtual ~NodeAttachment();
52 * Second-phase construction.
53 * This is called by the UpdateManager, when the attachment is attached to the scene-graph.
54 * @param[in] sceneController Allows attachments to get light/camera controllers.
55 * @param[in] updateBufferIndex The current update buffer index.
57 virtual void ConnectToSceneGraph( SceneController& sceneController, BufferIndex updateBufferIndex ) = 0;
60 * Called shortly before destruction.
61 * After this method has been called, the SceneController cannot be safely accessed.
63 virtual void OnDestroy() = 0;
66 * Set the parent of a NodeAttachment.
67 * @param[in] parent the new parent.
69 void SetParent( Node& parent );
72 * Retrieve the parent node of a NodeAttachment.
73 * @return The parent node, or NULL if the NodeAttachment has not been added to the scene-graph.
77 DALI_ASSERT_DEBUG( mParent != NULL );
82 * Retrieve the parent node of a NodeAttachment.
83 * @return The parent node, or NULL if the NodeAttachment has not been added to the scene-graph.
85 Node& GetParent() const
87 DALI_ASSERT_DEBUG( mParent != NULL );
91 // RenderableAttachment interface
94 * Query whether the attachment is renderable i.e. implements the SceneGraph::RenderableAttachment interface.
95 * @return True if the attachment is renderable.
99 return (GetRenderable() != NULL);
103 * Convert an attachment to a renderable attachment.
104 * @return A pointer to the renderable attachment, or NULL.
106 virtual RenderableAttachment* GetRenderable() = 0;
111 * Called when the attachment or it's owning node is flagged as dirty during scene graph updates.
112 * Allows derived classes to perform extra processing
113 * @param[in] updateBufferIndex The current update buffer index.
114 * @param[in] owningNode The attachment's owning node
115 * @param[in] nodeDirtyFlags of the owning node
117 virtual void Update( BufferIndex updateBufferIndex, const Node& owningNode, int nodeDirtyFlags ) {}
122 * Derived versions of NodeAttachment should be constructed.
129 NodeAttachment( const NodeAttachment& );
132 NodeAttachment& operator=( const NodeAttachment& rhs );
136 Node* mParent; ///< Pointer to parent node which owns the attachment.
139 } // namespace SceneGraph
141 } // namespace Internal
145 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_ATTACHMENT_H__