2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * This file contains the declaration of the NestedLoopManager class.
20 * @author Lukasz Marek (l.marek@samsung.com)
22 * @brief This file contains the declaration of the NestedLoopManager class.
25 #ifndef DPL_NESTED_LOOP_H_
26 #define DPL_NESTED_LOOP_H_
31 #include <dpl/event/controller.h>
32 #include <dpl/singleton.h>
43 typedef unsigned LoopHandle;
44 typedef std::list<LoopHandle> LoopHandleList;
46 const LoopHandle UNDEFINED_LOOP_HANDLE = 0;
48 class NestedLoopManager :
49 protected Controller<TypeListDecl<LoopExitEvent>::Type>
52 void* begin(LoopHandle loopHandle);
53 void exit(LoopHandle loopHandle,
54 void *userParam = NULL);
55 size_t getLevel() const;
56 LoopHandle getNewHandle();
59 void OnEventReceived(const LoopExitEvent& event);
62 struct LoopInformation
64 LoopInformation(LoopHandle handle) :
71 LoopHandle loopHandle;
76 class RunningLoopsHandlePredicate
79 RunningLoopsHandlePredicate(LoopHandle handle) :
84 bool operator()(const LoopInformation &loopInformation) const
86 return loopInformation.loopHandle == m_handle;
96 typedef std::vector<LoopInformation> RunningLoopsList;
97 typedef RunningLoopsList::iterator RunningLoopsListIterator;
99 bool m_eventGuard; // only one event is allowed
101 RunningLoopsList m_runningLoops;
103 friend class Singleton<NestedLoopManager>;
106 typedef Singleton<NestedLoopManager> NestedLoopManagerSingleton;
111 #endif // WRT_ENGINE_SRC_COMMON_NESTED_LOOP_H_