blob: 8029931f7c6a2d76b6436b2ff6132c0eed71d5fa [file] [log] [blame]
Adam Lesinski40e8eef2014-09-16 14:43:29 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
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#ifndef H_ANDROID_SPLIT_RULE
18#define H_ANDROID_SPLIT_RULE
19
20#include "SplitDescription.h"
21
22#include <utils/RefBase.h>
23#include <utils/StrongPointer.h>
24#include <utils/String8.h>
25#include <utils/Vector.h>
26
27namespace split {
28
29struct Rule : public virtual android::RefBase {
30 inline Rule();
31
32 enum Operator {
33 LESS_THAN = 1,
34 GREATER_THAN,
35 EQUALS,
36 CONTAINS_ANY,
37 CONTAINS_ALL,
38 IS_TRUE,
39 IS_FALSE,
40 AND_SUBRULES,
41 OR_SUBRULES,
42 ALWAYS_TRUE,
43 };
44
45 Operator op;
46
47 enum Key {
48 NONE = 0,
49 SDK_VERSION,
50 SCREEN_DENSITY,
51 LANGUAGE,
52 NATIVE_PLATFORM,
53 TOUCH_SCREEN,
54 SCREEN_SIZE,
55 SCREEN_LAYOUT,
56 };
57
58 Key key;
59 bool negate;
60
61 android::Vector<android::String8> stringArgs;
62 android::Vector<int> longArgs;
63 android::Vector<double> doubleArgs;
64 android::Vector<android::sp<Rule> > subrules;
65
66 android::String8 toJson(int indent=0) const;
67
68 static android::sp<Rule> simplify(android::sp<Rule> rule);
69};
70
71Rule::Rule()
72: op(ALWAYS_TRUE)
73, key(NONE)
74, negate(false) {}
75
76} // namespace split
77
78#endif // H_ANDROID_SPLIT_RULE