Orderable.h revision e507721000647a7d8afe44c63ef7fd04ef8971b1
1/*
2 * Copyright 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 IMG_UTILS_ORDERABLE
18#define IMG_UTILS_ORDERABLE
19
20#include <cutils/compiler.h>
21#include <stdint.h>
22
23namespace android {
24namespace img_utils {
25
26#define COMPARE_DEF(op) \
27inline bool operator op (const Orderable& orderable) const;
28
29/**
30 * Subclasses of Orderable can be compared and sorted.  This is
31 * intended to be used to create sorted arrays of TIFF entries
32 * and IFDs.
33 */
34class ANDROID_API Orderable  {
35    public:
36        virtual ~Orderable();
37
38        /**
39         * Comparison operatotors are based on the value returned
40         * from this method.
41         */
42        virtual uint32_t getComparableValue() const = 0;
43
44        COMPARE_DEF(>)
45        COMPARE_DEF(<)
46        COMPARE_DEF(>=)
47        COMPARE_DEF(<=)
48        COMPARE_DEF(==)
49        COMPARE_DEF(!=)
50};
51
52#undef COMPARE_DEF
53
54} /*namespace img_utils*/
55} /*namespace android*/
56
57#endif /*IMG_UTILS_ORDERABLE*/
58