Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / platform / Tizen / Mediacontent / MediaSearchVisitor.h
1 /*
2 * Copyright (c) 2011 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
18 #ifndef _PLATFORM_MEDIA_CONTENT_SEARCH_VISITOR_H_
19 #define _PLATFORM_MEDIA_CONTENT_SEARCH_VISITOR_H_
20
21 #include <map>
22 #include <string>
23 #include <dpl/shared_ptr.h>
24 #include <API/Filter/IFilter.h>
25 #include <API/Filter/IFilterVisitor.h>
26 #include <API/Filter/SortMode.h>
27
28 #include <API/Mediacontent/IMediacontent.h>
29
30 using namespace TizenApis::Api::Tizen;
31 using namespace WrtDeviceApis::Commons;
32 using namespace std;
33
34
35
36 namespace TizenApis {
37 namespace Platform {
38 namespace Mediacontent {
39         
40 typedef enum
41 {
42         EQUAL,
43         NOT_EQUAL,
44         GREATER_THAN,
45         LESS_THAN,
46         GREATER_THAN_OR_EQUAL,
47         LESS_THAN_OR_EQUAL,
48         LIKE,
49         EXISTS,
50         CONDITION_MAX
51 }condition_e;
52
53 static string operatorKey[] =
54 {
55         " = ",
56         " != ",
57         " > ",
58         " < ",
59         " >= ",
60         " <= ",
61         " like "
62 };
63
64 class MediaSearchVisitor : public TizenApis::Api::Tizen::IFilterVisitor
65 {
66 public:
67         typedef enum _QueryType { QUERY_FOLDER, QUERY_MEDIA } QueryType;
68
69         
70         MediaSearchVisitor();
71         virtual ~MediaSearchVisitor();
72
73         virtual void visitPreComposite(FilterType& type, int depth);
74         virtual void visitInComposite(FilterType& type, int depth);
75         virtual void visitPostComposite(FilterType& type, int depth);
76         virtual void visitAttribute(string& attrName, MatchFlag& matchFlag, AnyArrayPtr& matchValues, int depth);
77         virtual void visitAttributeRange(string& attrName,AnyPtr& initialValue,AnyPtr& endValue,int depth);
78
79         string getPlatformAttr(string attrName);
80         string getResult() const;
81
82         void setQueryType(QueryType value);
83         
84 private:
85         string toDateDbStr(const tm &date) const;
86         string convertAttribute(string &attrname, AnyPtr& matchValue, MatchFlag& matchFlag);
87                 
88 private:
89         QueryType queryType;
90         string m_query; 
91         static map<string, string> attrFolderEnumMap;
92         static map<string, string> attrMediaEnumMap;
93
94 };
95
96 typedef DPL::SharedPtr<MediaSearchVisitor> MediaSearchVisitorPtr;
97
98 } // Mediacontent
99 } // Platform
100 } // TizenApis
101
102 #endif // _PLATFORM_MEDIA_CONTENT_SEARCH_VISITOR_H_