Dali 3D User Interface Engine
singleton-service-impl.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_SINGLETON_SERVICE_H__
2 #define __DALI_INTERNAL_SINGLETON_SERVICE_H__
3 
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20 
21 // EXTERNAL INCLUDES
24 
25 // INTERNAL INCLUDES
26 #include <singleton-service.h>
27 
28 namespace Dali
29 {
30 
31 namespace Internal
32 {
33 
34 namespace Adaptor
35 {
36 
38 {
39 public:
40 
46  static Dali::SingletonService New();
47 
51  static Dali::SingletonService Get();
52 
56  void Register( const std::type_info& info, BaseHandle singleton );
57 
61  void UnregisterAll();
62 
66  BaseHandle GetSingleton( const std::type_info& info ) const;
67 
68 private:
69 
75 
79  virtual ~SingletonService();
80 
81  // Undefined
84 
85 private:
86 
87  typedef std::pair<std::string, BaseHandle> SingletonPair;
88  typedef std::map<std::string, BaseHandle> SingletonContainer;
89  typedef SingletonContainer::const_iterator SingletonConstIter;
90 
92 };
93 
94 } // namespace Adaptor
95 
96 } // namespace Internal
97 
98 // Helpers for public-api forwarding methods
99 
101 {
102  DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
103 
104  BaseObject& handle = player.GetBaseObject();
105 
106  return static_cast<Internal::Adaptor::SingletonService&>(handle);
107 }
108 
110 {
111  DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
112 
113  const BaseObject& handle = player.GetBaseObject();
114 
115  return static_cast<const Internal::Adaptor::SingletonService&>(handle);
116 }
117 
118 } // namespace Dali
119 
120 #endif // __DALI_INTERNAL_SINGLETON_SERVICE_H__
Dali Docs Home
Read more about Dali