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 <cstddef> // NULL
25 #include <dali/internal/common/message.h>
37 class RenderableAttachment;
38 class SceneController;
41 * NodeAttachment is a base class for objects attached to Nodes in the scene graph.
42 * The position of the object is provided by its parent node.
43 * NodeAttachment data is double-buffered. This allows an update thread to modify node data, without interferring
44 * with another thread reading the values from the previous update traversal.
53 virtual ~NodeAttachment();
56 * Second-phase construction.
57 * This is called by the UpdateManager when the attachment is attached to the scene-graph.
58 * @param[in] sceneController Allows attachments to get camera controllers.
59 * @param[in] updateBufferIndex The current update buffer index.
61 virtual void Initialize( SceneController& sceneController, BufferIndex updateBufferIndex ) = 0;
64 * Called shortly before destruction.
65 * After this method has been called, the SceneController cannot be safely accessed.
67 virtual void OnDestroy() = 0;
70 * Called when the parent node is connected to the SceneGraph
72 virtual void ConnectedToSceneGraph() = 0;
75 * Called when the parent node is disconnected from the SceneGraph
77 virtual void DisconnectedFromSceneGraph( ) = 0;
80 * Set the parent of a NodeAttachment.
81 * @param[in] parent the new parent.
83 void SetParent( Node& parent );
86 * Retrieve the parent node of a NodeAttachment.
87 * @return The parent node, or NULL if the NodeAttachment has not been added to the scene-graph.
91 DALI_ASSERT_DEBUG( mParent != NULL );
96 * Retrieve the parent node of a NodeAttachment.
97 * @return The parent node, or NULL if the NodeAttachment has not been added to the scene-graph.
99 Node& GetParent() const
101 DALI_ASSERT_DEBUG( mParent != NULL );
105 // RenderableAttachment interface
108 * Query whether the attachment is renderable i.e. implements the SceneGraph::RenderableAttachment interface.
109 * @return True if the attachment is renderable.
113 return (GetRenderable() != NULL);
117 * Convert an attachment to a renderable attachment.
118 * @return A pointer to the renderable attachment, or NULL.
120 virtual RenderableAttachment* GetRenderable() = 0;
125 * Called to reset attachment's properties to base values.
126 * Attachments without properties should not override this method
128 virtual void ResetToBaseValues(BufferIndex bufferIndex) { }
131 * Called when the attachment or it's owning node is flagged as dirty during scene graph updates.
132 * Allows derived classes to perform extra processing
133 * @param[in] updateBufferIndex The current update buffer index.
134 * @param[in] owningNode The attachment's owning node
135 * @param[in] nodeDirtyFlags of the owning node
137 virtual void Update( BufferIndex updateBufferIndex, const Node& owningNode, int nodeDirtyFlags ) {}
142 * Derived versions of NodeAttachment should be constructed.
149 NodeAttachment( const NodeAttachment& );
152 NodeAttachment& operator=( const NodeAttachment& rhs );
156 Node* mParent; ///< Pointer to parent node which owns the attachment.
159 } // namespace SceneGraph
161 } // namespace Internal
165 #endif // __DALI_INTERNAL_SCENE_GRAPH_NODE_ATTACHMENT_H__