1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifndef SCENE_SRC_STARTABLE_HANDLER_H
17 #define SCENE_SRC_STARTABLE_HANDLER_H
18
19 #include <scene/ext/intf_internal_scene.h>
20 #include <scene/interface/intf_node.h>
21 #include <scene/interface/intf_scene.h>
22
SCENE_BEGIN_NAMESPACE()23 SCENE_BEGIN_NAMESPACE()
24
25 class StartableHandler {
26 public:
27 enum class StartType : uint8_t {
28 DEFERRED = 0,
29 DIRECT = 1,
30 };
31
32 StartableHandler() = delete;
33 StartableHandler(const INode::Ptr& node) : node_(node) {}
34 virtual ~StartableHandler() = default;
35 bool Start(const META_NS::IObject::Ptr& attachment, StartType type);
36 bool Stop(const META_NS::IObject::Ptr& attachment);
37 bool StartAll(StartType type);
38 bool StopAll();
39 bool StopAll(const META_NS::IContainer::Ptr& container);
40
41 private:
42 IInternalScene::Ptr GetScene() const;
43 INode::WeakPtr node_;
44 };
45
46 namespace Internal {
47
48 bool StartStartable(
49 const IInternalScene::Ptr& scene, StartableHandler::StartType type, const META_NS::IObject::Ptr& object);
50 bool StopStartable(const META_NS::IObject::Ptr& object);
51
52 bool StartAllStartables(
53 const IInternalScene::Ptr& scene, StartableHandler::StartType type, const META_NS::IObject::Ptr& object);
54 bool StopAllStartables(const META_NS::IObject::Ptr& object);
55
56 } // namespace Internal
57
58 SCENE_END_NAMESPACE()
59
60 #endif // SCENE_SRC_STARTABLE_HANDLER_H
61