1 #ifndef __DALI_INTERNAL_SINGLETON_SERVICE_H__
2 #define __DALI_INTERNAL_SINGLETON_SERVICE_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 <dali/public-api/object/base-object.h>
23 #include <dali/devel-api/common/map-wrapper.h>
26 #include <singleton-service.h>
37 class SingletonService : public Dali::BaseObject
42 * Create a SingletonService.
43 * This should only be called once by the Application class.
44 * @return A newly created SingletonService.
46 static Dali::SingletonService New();
49 * @copydoc Dali::SingletonService::Get()
51 static Dali::SingletonService Get();
54 * @copydoc Dali::SingletonService::Register()
56 void Register( const std::type_info& info, BaseHandle singleton );
59 * @copydoc Dali::SingletonService::UnregisterAll()
64 * @copydoc Dali::SingletonService::GetSingleton()
66 BaseHandle GetSingleton( const std::type_info& info ) const;
72 * @see SingletonService::New()
79 virtual ~SingletonService();
82 SingletonService( const SingletonService& );
83 SingletonService& operator=( SingletonService& );
87 typedef std::pair<std::string, BaseHandle> SingletonPair;
88 typedef std::map<std::string, BaseHandle> SingletonContainer;
89 typedef SingletonContainer::const_iterator SingletonConstIter;
91 SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name
94 } // namespace Adaptor
96 } // namespace Internal
98 // Helpers for public-api forwarding methods
100 inline Internal::Adaptor::SingletonService& GetImplementation(Dali::SingletonService& player)
102 DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
104 BaseObject& handle = player.GetBaseObject();
106 return static_cast<Internal::Adaptor::SingletonService&>(handle);
109 inline const Internal::Adaptor::SingletonService& GetImplementation(const Dali::SingletonService& player)
111 DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );
113 const BaseObject& handle = player.GetBaseObject();
115 return static_cast<const Internal::Adaptor::SingletonService&>(handle);
120 #endif // __DALI_INTERNAL_SINGLETON_SERVICE_H__