Pepper_56_C++_interfaces
Pepper_56_C++_interfaces
 All Classes Namespaces Files Functions Typedefs Enumerations Macros Groups
resource.h
Go to the documentation of this file.
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef PPAPI_CPP_RESOURCE_H_
6 #define PPAPI_CPP_RESOURCE_H_
7 
8 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/cpp/pass_ref.h"
11 
15 namespace pp {
16 
17 class Var;
18 
20 class Resource {
21  public:
23  Resource();
24 
28  Resource(const Resource& other);
29 
31  virtual ~Resource();
32 
39  Resource& operator=(const Resource& other);
40 
45  bool is_null() const { return !pp_resource_; }
46 
47  PP_Resource pp_resource() const { return pp_resource_; }
48 
56  PP_Resource detach();
57 
58  protected:
64  explicit Resource(PP_Resource resource);
65 
68  Resource(PassRef, PP_Resource resource);
69 
84  void PassRefFromConstructor(PP_Resource resource);
85 
87  void Clear();
88 
89  private:
90  friend class Var;
91 
92  PP_Resource pp_resource_;
93 };
94 
95 } // namespace pp
96 
97 inline bool operator==(const pp::Resource& lhs, const pp::Resource& rhs) {
98  return lhs.pp_resource() == rhs.pp_resource();
99 }
100 
101 inline bool operator!=(const pp::Resource& lhs, const pp::Resource& rhs) {
102  return !(lhs == rhs);
103 }
104 
105 #endif // PPAPI_CPP_RESOURCE_H_
void PassRefFromConstructor(PP_Resource resource)
Resource()
The default constructor.
PP_Resource detach()
Resource & operator=(const Resource &other)
virtual ~Resource()
Destructor.
PassRef
Definition: pass_ref.h:17
bool is_null() const
Definition: resource.h:45
A reference counted module resource.
Definition: resource.h:20
bool operator!=(const pp::Point &lhs, const pp::Point &rhs)
Definition: point.h:313
void Clear()
Sets this resource to null. This releases ownership of the resource.
bool operator==(const pp::Point &lhs, const pp::Point &rhs)
Definition: point.h:302