blob: 864b41b3f24d7c4d454f027d352c698a98763dce [file] [log] [blame]
Yifan Hongb0dde932017-02-10 17:49:58 -08001/*
2 * Copyright (C) 2016 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 FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_
18#define FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_
19
20#include <stdint.h>
21
22#include <string>
23#include <vector>
Yifan Hong38d53e02017-02-13 17:51:59 -080024#include <iostream>
Yifan Hongb0dde932017-02-10 17:49:58 -080025
26namespace android {
27namespace lshal {
28
29using Pids = std::vector<int32_t>;
30
31struct TableEntry {
32 std::string interfaceName;
33 std::string transport;
34 int32_t serverPid;
35 uint64_t serverObjectAddress;
36 Pids clientPids;
Yifan Hong38d53e02017-02-13 17:51:59 -080037
38 static bool sortByInterfaceName(const TableEntry &a, const TableEntry &b) {
39 return a.interfaceName < b.interfaceName;
40 };
41 static bool sortByServerPid(const TableEntry &a, const TableEntry &b) {
42 return a.serverPid < b.serverPid;
43 };
Yifan Hongb0dde932017-02-10 17:49:58 -080044};
45
46using Table = std::vector<TableEntry>;
Yifan Hong38d53e02017-02-13 17:51:59 -080047using TableEntryCompare = std::function<bool(const TableEntry &, const TableEntry &)>;
48
49enum : unsigned int {
50 ENABLE_INTERFACE_NAME = 1 << 0,
51 ENABLE_TRANSPORT = 1 << 1,
52 ENABLE_SERVER_PID = 1 << 2,
53 ENABLE_SERVER_ADDR = 1 << 3,
54 ENABLE_CLIENT_PIDS = 1 << 4
55};
56
57using TableEntrySelect = unsigned int;
Yifan Hongb0dde932017-02-10 17:49:58 -080058
59enum {
60 NO_PID = -1,
61 NO_PTR = 0
62};
63
64} // namespace lshal
65} // namespace android
66
67#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_TABLE_ENTRY_H_