adb_endpoint_object.h revision 5c11852110eeb03dc5a69111354b383f98d15336
1/*
2 * Copyright (C) 2006 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 ANDROID_USB_API_ADB_ENDPOINT_OBJECT_H__
18#define ANDROID_USB_API_ADB_ENDPOINT_OBJECT_H__
19/** \file
20  This file consists of declaration of class AdbIOObject that encapsulates a
21  handle opened to an endpoint on our device.
22*/
23
24#include "adb_io_object.h"
25
26/** Class AdbEndpointObject encapsulates a handle opened to an endpoint on
27  our device.
28*/
29class AdbEndpointObject : public AdbIOObject {
30 public:
31  /** \brief Constructs the object
32
33    @param interface[in] Parent interface for this object. Interface will be
34           referenced in this object's constructur and released in the
35           destructor.
36    @param obj_type[in] Object type from AdbObjectType enum
37  */
38  AdbEndpointObject(AdbInterfaceObject* parent_interf);
39
40 protected:
41  /** \brief Destructs the object.
42
43    parent_interface_ will be dereferenced here.
44    We hide destructor in order to prevent ourseves from accidentaly allocating
45    instances on the stack. If such attemp occur, compiler will error.
46  */
47  virtual ~AdbEndpointObject();
48
49 public:
50  /** \brief Gets information about this endpoint.
51
52    @param info[out] Upon successful completion will have endpoint information.
53    @return 'true' on success, 'false' on failure. If 'false' is returned
54            GetLastError() provides extended error information.
55  */
56  bool GetEndpointInformation(AdbEndpointInformation* info);
57
58  /** \brief Checks if this object is of the given type
59
60    @param obj_type[in] One of the AdbObjectType types to check
61    @return 'true' is this object type matches obj_type and 'false' otherwise.
62  */
63  virtual bool IsObjectOfType(AdbObjectType obj_type) const;
64
65  // This is a helper for extracting object from the AdbObjectHandleMap
66  static AdbObjectType Type() {
67    return AdbObjectTypeEndpoint;
68  }
69};
70
71#endif  // ANDROID_USB_API_ADB_ENDPOINT_OBJECT_H__
72