1 #ifndef __DALI_SINGELTON_SERVICE_H__
2 #define __DALI_SINGELTON_SERVICE_H__
5 * Copyright (c) 2015 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.
23 #include <dali/public-api/object/base-handle.h>
28 namespace Internal DALI_INTERNAL
32 class SingletonService;
37 * @brief Allows the registration of a class as a singleton
39 * @note This class is created by the Application class and is destroyed when the Application class is destroyed.
43 class DALI_IMPORT_API SingletonService : public BaseHandle
48 * @brief Create an uninitialized handle.
50 * This can be initialized by calling SingletonService::Get().
55 * Create a SingletonService.
56 * This should only be called once by the Application class.
57 * @return A newly created SingletonService.
59 static Dali::SingletonService New();
62 * @brief Retrieves a handle to the SingletonService.
64 * @return A handle to the SingletonService if it is available. This will be an empty handle if
65 * the service is not available.
67 static SingletonService Get();
72 * This is non-virtual since derived Handle types must not contain data or virtual methods.
77 * @brief Registers the singleton of Dali handle with its type info.
79 * The singleton will be kept alive for the lifetime of the service.
81 * @note This is not intended for application developers.
82 * @param[in] info The type info of the Dali handle generated by the compiler.
83 * @param[in] singleton The Dali handle to be registered
85 void Register( const std::type_info& info, BaseHandle singleton );
88 * @brief Unregisters all singletons.
90 * @note This is not intended for application developers.
95 * @brief Gets the singleton for the given type.
97 * @note This is not intended for application developers.
98 * @param[in] info The type info of the given type.
99 * @return the Dali handle if it is registered as a singleton or an uninitialized handle.
101 BaseHandle GetSingleton( const std::type_info& info ) const;
103 public: // Not intended for application developers
106 * @brief This constructor is used by SingletonService::Get().
107 * @param[in] singletonService A pointer to the internal singleton-service object.
109 explicit DALI_INTERNAL SingletonService( Internal::Adaptor::SingletonService* singletonService );
114 #endif // __DALI_SINGELTON_SERVICE_H__