dbg.h file is removed.
[profile/tv/apps/native/filebrowser.git] / src / data / FileList.cpp
1 /*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #include <cstdio>
18 #include <cstdlib>
19
20 #include <AppCommon.h>
21 #include "common.h"
22 #include "FileList.h"
23
24 int CFileList::t_Max(void)
25 {
26         return m_max;
27 }
28
29 void CFileList::t_Remove(Eina_List** list)
30 {
31         _DBG("");
32         if (*list == NULL)
33                 return;
34
35         Eina_List* filelist = *list;
36         CExtNameInfo *pInfo;
37         void* obj;
38
39         EINA_LIST_FREE(filelist, obj) {
40                 pInfo = (CExtNameInfo *)obj;
41                 pInfo->Destroy();
42                 delete pInfo;
43         }
44
45         *list = NULL;
46 }
47
48 CFileList::CFileList(int max)
49 {
50         m_lists = new Eina_List*[max + 1];
51         for (int a = 0; a <= max; a++)
52                 m_lists[a] = NULL;
53
54         m_max = max;
55 }
56
57 CFileList::~CFileList()
58 {
59         RemoveAll();
60         delete[] m_lists;
61         m_lists = NULL;
62 }
63
64 void CFileList::Add(int idx, void* obj)
65 {
66         ASSERT(0 <= idx && idx <= t_Max());
67         m_lists[idx] = eina_list_append(m_lists[idx], obj);
68 }
69
70 Eina_List* CFileList::Clone(int idx)
71 {
72         ASSERT(0 <= idx && idx <= t_Max());
73         return eina_list_clone(m_lists[idx]);
74 }
75
76 void CFileList::RemoveAll(void)
77 {
78         for (int a = 0; a <= t_Max(); a++)
79                 t_Remove(&m_lists[a]);
80 }