1e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck/*
252244fff29042926e21fa897ef5ab11148e35299John Reck * Copyright (C) 2014 The Android Open Source Project
3e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *
4e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Licensed under the Apache License, Version 2.0 (the "License");
5e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * you may not use this file except in compliance with the License.
6e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * You may obtain a copy of the License at
7e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *
8e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *      http://www.apache.org/licenses/LICENSE-2.0
9e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck *
10e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * Unless required by applicable law or agreed to in writing, software
11e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * distributed under the License is distributed on an "AS IS" BASIS,
12e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * See the License for the specific language governing permissions and
14e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck * limitations under the License.
15e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck */
1652244fff29042926e21fa897ef5ab11148e35299John Reck#ifndef MACROS_H
1752244fff29042926e21fa897ef5ab11148e35299John Reck#define MACROS_H
18e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
1952244fff29042926e21fa897ef5ab11148e35299John Reck#define PREVENT_COPY_AND_ASSIGN(Type) \
2052244fff29042926e21fa897ef5ab11148e35299John Reck    private: \
2152244fff29042926e21fa897ef5ab11148e35299John Reck        Type(const Type&); \
2252244fff29042926e21fa897ef5ab11148e35299John Reck        void operator=(const Type&)
23e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck
2405f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik#define DESCRIPTION_TYPE(Type) \
2505f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik        int compare(const Type& rhs) const { return memcmp(this, &rhs, sizeof(Type));} \
2605f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik        bool operator==(const Type& other) const { return compare(other) == 0; } \
2705f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik        bool operator!=(const Type& other) const { return compare(other) != 0; } \
2805f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik        friend inline int strictly_order_type(const Type& lhs, const Type& rhs) { return lhs.compare(rhs) < 0; } \
2905f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik        friend inline int compare_type(const Type& lhs, const Type& rhs) { return lhs.compare(rhs); } \
3005f3d6e5111fd08df5cd9aae2c3d28399dc0e7f5Chris Craik        friend inline hash_t hash_type(const Type& entry) { return entry.hash(); }
31496b8770c19c573299e4be525e877acc977a2dadJohn Reck
3252244fff29042926e21fa897ef5ab11148e35299John Reck#endif /* MACROS_H */
33