1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  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,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef INCLUDED_SLIDESHOW_BASECONTAINERNODE_HXX
24 #define INCLUDED_SLIDESHOW_BASECONTAINERNODE_HXX
25 
26 #include "basenode.hxx"
27 
28 namespace slideshow {
29 namespace internal {
30 
31 /** This interface extends BaseNode with child handling methods.
32     Used for XAnimationNode objects which have children
33 */
34 class BaseContainerNode : public BaseNode
35 {
36 public:
37     BaseContainerNode(
38         ::com::sun::star::uno::Reference<
39         ::com::sun::star::animations::XAnimationNode> const& xNode,
40         ::boost::shared_ptr<BaseContainerNode> const& pParent,
41         NodeContext const& rContext );
42 
43     /** Add given child node to this container
44      */
45     void appendChildNode( AnimationNodeSharedPtr const& pNode );
46 
47 #if defined(VERBOSE) && defined(DBG_UTIL)
48     virtual void showState() const;
getDescription() const49     virtual const char* getDescription() const { return "BaseContainerNode"; }
50 #endif
51 
52 protected:
53     // overrides from BaseNode
54     virtual void dispose();
55 
56 private:
57     virtual bool init_st();
58     virtual void deactivate_st( NodeState eDestState );
59     virtual bool hasPendingAnimation() const;
60     // force to be implemented by derived class:
61     virtual void activate_st() = 0;
62     virtual void notifyDeactivating(
63         AnimationNodeSharedPtr const& rNotifier ) = 0;
64 
65 protected:
isDurationIndefinite() const66     bool isDurationIndefinite() const { return mbDurationIndefinite; }
67 
68     bool isChildNode( AnimationNodeSharedPtr const& pNode ) const;
69 
70     /// @return true: if all children have been deactivated
71     bool notifyDeactivatedChild( AnimationNodeSharedPtr const& pChildNode );
72 
73     template <typename FuncT>
forEachChildNode(FuncT const & func,int nodeStateMask=-1) const74     inline void forEachChildNode( FuncT const& func,
75                                   int nodeStateMask = -1 ) const
76     {
77         VectorOfNodes::const_iterator iPos( maChildren.begin() );
78         VectorOfNodes::const_iterator const iEnd( maChildren.end() );
79         for ( ; iPos != iEnd; ++iPos ) {
80             AnimationNodeSharedPtr const& pNode = *iPos;
81             if (nodeStateMask != -1 && (pNode->getState() & nodeStateMask) == 0)
82                 continue;
83             func(pNode);
84         }
85     }
86 
87     typedef ::std::vector<AnimationNodeSharedPtr> VectorOfNodes;
88     VectorOfNodes       maChildren;
89     ::std::size_t       mnFinishedChildren;
90 
91 private:
92     const bool          mbDurationIndefinite;
93 };
94 
95 typedef ::boost::shared_ptr< BaseContainerNode > BaseContainerNodeSharedPtr;
96 
97 } // namespace interface
98 } // namespace presentation
99 
100 #endif /* INCLUDED_SLIDESHOW_BASECONTAINERNODE_HXX */
101 
102