2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FCntPlayListManager.cpp
19 * @brief This is the implementation file for the %PlayListManager class.
21 * This is the implementation file for %PlayListManager class.
27 #include <FBaseSysLog.h>
28 #include <FCntPlayListManager.h>
29 #include <FBaseColIList.h>
31 #include <FSysEnvironment.h>
32 #include <FCnt_PlayListManagerImpl.h>
34 using namespace Tizen::Io;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::System;
39 namespace Tizen { namespace Content
42 PlayListManager* PlayListManager::__pPlayListManager = NULL;
44 PlayListManager::PlayListManager(void)
50 PlayListManager::~PlayListManager(void)
56 PlayListManager::GetInstance(void)
58 static pthread_once_t onceBlock = PTHREAD_ONCE_INIT;
60 if (!__pPlayListManager)
63 pthread_once(&onceBlock, InitSingleton);
64 result r = GetLastResult();
67 onceBlock = PTHREAD_ONCE_INIT;
70 return __pPlayListManager;
74 PlayListManager::InitSingleton(void)
76 __pPlayListManager = new (std::nothrow) PlayListManager();
77 SysTryReturnVoidResult(NID_CNT, __pPlayListManager, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
79 result r = __pPlayListManager->Construct();
80 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating from PlayListManager Construct.", GetErrorMessage(r));
82 atexit(DestroySingleton);
87 delete __pPlayListManager;
91 PlayListManager::DestroySingleton(void)
93 delete __pPlayListManager;
97 PlayListManager::Construct(void)
101 SysAssertf(__pImpl == null,
102 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
104 _PlayListManagerImpl* pPlayListManagerImpl = new (std::nothrow) _PlayListManagerImpl();
105 SysTryReturn(NID_CNT, pPlayListManagerImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
107 r = pPlayListManagerImpl->Construct();
108 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
110 __pImpl = pPlayListManagerImpl;
115 delete pPlayListManagerImpl;
120 PlayListManager::GetPlayListN(const Tizen::Base::String& playListName) const
124 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
126 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
128 return __pImpl->GetPlayListN(playListName);
132 PlayListManager::RemovePlayList(const Tizen::Base::String& playListName)
134 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
136 SysTryReturn(NID_CNT, !playListName.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The playListName is empty.");
138 return __pImpl->RemovePlayList(playListName);
142 PlayListManager::GetAllPlayListCount(void) const
146 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
148 return __pImpl->GetAllPlayListCount();
151 Tizen::Base::Collection::IList*
152 PlayListManager::GetAllPlayListNameN(void) const
156 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
158 return __pImpl->GetAllPlayListNameN();