Remove key defs
[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 <stdio.h>
18 #include <stdlib.h>
19 #include <Eina.h>
20 #include "dbg.h"
21 #include "common.h"
22 #include "i18n.h"
23
24 #include <media_content.h>
25 #include "AppCommon.h"
26 #include "ExtNameInfo.h"
27 #include "FileList.h"
28
29 int CFileList::t_Max(void)
30 {
31         return m_max;
32 }
33
34 void CFileList::t_Remove(Eina_List** list)
35 {
36         _DBG("");
37         if (*list == NULL)
38                 return;
39
40         Eina_List* filelist = *list;
41         CExtNameInfo *pInfo;
42         void* obj;
43
44         EINA_LIST_FREE(filelist, obj) {
45                 pInfo = (CExtNameInfo *)obj;
46                 pInfo->Destroy();
47                 delete pInfo;
48         }
49
50         *list = NULL;
51 }
52
53 CFileList::CFileList(int max)
54 {
55         m_lists = new Eina_List*[max + 1];
56         for (int a = 0; a <= max; a++)
57                 m_lists[a] = NULL;
58
59         m_max = max;
60 }
61
62 CFileList::~CFileList()
63 {
64         RemoveAll();
65         delete[] m_lists;
66         m_lists = NULL;
67 }
68
69 void CFileList::Add(int idx, void* obj)
70 {
71         ASSERT(0 <= idx && idx <= t_Max());
72         m_lists[idx] = eina_list_append(m_lists[idx], obj);
73 }
74
75 Eina_List* CFileList::Clone(int idx)
76 {
77         ASSERT(0 <= idx && idx <= t_Max());
78         return eina_list_clone(m_lists[idx]);
79 }
80
81 void CFileList::RemoveAll(void)
82 {
83         for (int a = 0; a <= t_Max(); a++)
84                 t_Remove(&m_lists[a]);
85 }