/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if( singleton )
{
DALI_LOG_SINGLETON_SERVICE( Debug::General, "Singleton Added: %s\n", info.name() );
- mSingletonContainer.insert( SingletonPair( info.name(), singleton ) );
+ mSingletonContainer.push_back( SingletonPair( info.name(), singleton ) );
}
}
{
BaseHandle object;
- SingletonConstIter iter = mSingletonContainer.find(info.name());
- if( iter != mSingletonContainer.end() )
+ const SingletonContainer::const_iterator end = mSingletonContainer.end();
+ for( SingletonContainer::const_iterator iter = mSingletonContainer.begin(); iter != end; ++iter )
{
- object = ( *iter ).second;
+ // comparing the addresses as these are allocated statically per library
+ if( ( *iter ).first == info.name() )
+ {
+ object = ( *iter ).second;
+ }
}
return object;
#define __DALI_INTERNAL_SINGLETON_SERVICE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <dali/public-api/object/base-object.h>
-#include <dali/devel-api/common/map-wrapper.h>
+#include <dali/public-api/common/vector-wrapper.h>
// INTERNAL INCLUDES
#include <singleton-service.h>
private:
- typedef std::pair<std::string, BaseHandle> SingletonPair;
- typedef std::map<std::string, BaseHandle> SingletonContainer;
+ // using the address of the type name string as compiler will allocate these once per library
+ // and we don't support un/re-loading of dali libraries while singleton service is alive
+ typedef std::pair< const char*, BaseHandle> SingletonPair;
+ typedef std::vector< SingletonPair > SingletonContainer;
typedef SingletonContainer::const_iterator SingletonConstIter;
SingletonContainer mSingletonContainer; ///< The container to look up singleton by its type name