2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 * @file FCntPlayListManager.cpp
18 * @brief This is the implementation file for the %PlayListManager class.
20 * This is the implementation file for %PlayListManager class.
26 #include <FBaseSysLog.h>
27 #include <FCntPlayListManager.h>
28 #include <FBaseColIList.h>
30 #include <FSysEnvironment.h>
31 #include <FCnt_PlayListManagerImpl.h>
33 using namespace Tizen::Io;
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36 using namespace Tizen::System;
38 namespace Tizen { namespace Content
41 PlayListManager* PlayListManager::__pPlayListManager = NULL;
43 PlayListManager::PlayListManager(void)
49 PlayListManager::~PlayListManager(void)
55 PlayListManager::GetInstance(void)
57 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
59 if (!__pPlayListManager)
62 pthread_once(&onceBlock, InitSingleton);
63 result r = GetLastResult();
66 onceBlock = PTHREAD_ONCE_INIT;
69 return __pPlayListManager;
73 PlayListManager::InitSingleton(void)
75 __pPlayListManager = new (std::nothrow) PlayListManager();
76 SysTryReturnVoidResult(NID_CNT, __pPlayListManager, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
78 result r = __pPlayListManager->Construct();
79 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating from PlayListManager Construct.", GetErrorMessage(r));
81 atexit(DestroySingleton);
86 delete __pPlayListManager;
90 PlayListManager::DestroySingleton(void)
92 delete __pPlayListManager;
96 PlayListManager::Construct(void)
100 SysAssertf(__pImpl == null,
101 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
103 _PlayListManagerImpl* pPlayListManagerImpl = new (std::nothrow) _PlayListManagerImpl();
104 SysTryReturn(NID_CNT, pPlayListManagerImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
106 r = pPlayListManagerImpl->Construct();
107 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
109 __pImpl = pPlayListManagerImpl;
114 delete pPlayListManagerImpl;
119 PlayListManager::GetPlayListN(const Tizen::Base::String& playListName) const
123 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
125 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
127 return __pImpl->GetPlayListN(playListName);
131 PlayListManager::RemovePlayList(const Tizen::Base::String& playListName)
133 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
135 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
137 return __pImpl->RemovePlayList(playListName);
141 PlayListManager::GetAllPlayListCount(void) const
145 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
147 return __pImpl->GetAllPlayListCount();
150 Tizen::Base::Collection::IList*
151 PlayListManager::GetAllPlayListNameN(void) const
155 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
157 return __pImpl->GetAllPlayListNameN();