Corentin Wallez | 9e4518b | 2018-10-15 12:54:30 +0000 | [diff] [blame] | 1 | // Copyright 2018 The Dawn Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef DAWNNATIVE_OBJECTBASE_H_ |
| 16 | #define DAWNNATIVE_OBJECTBASE_H_ |
| 17 | |
Rafael Cintron | 7e8385c | 2020-04-20 17:36:22 +0000 | [diff] [blame] | 18 | #include "common/RefCounted.h" |
Corentin Wallez | 9e4518b | 2018-10-15 12:54:30 +0000 | [diff] [blame] | 19 | |
| 20 | namespace dawn_native { |
| 21 | |
| 22 | class DeviceBase; |
| 23 | |
| 24 | class ObjectBase : public RefCounted { |
| 25 | public: |
Corentin Wallez | a594f8f | 2019-02-13 13:09:18 +0000 | [diff] [blame] | 26 | struct ErrorTag {}; |
| 27 | static constexpr ErrorTag kError = {}; |
| 28 | |
Corentin Wallez | 9e4518b | 2018-10-15 12:54:30 +0000 | [diff] [blame] | 29 | ObjectBase(DeviceBase* device); |
Corentin Wallez | a594f8f | 2019-02-13 13:09:18 +0000 | [diff] [blame] | 30 | ObjectBase(DeviceBase* device, ErrorTag tag); |
Corentin Wallez | 9e4518b | 2018-10-15 12:54:30 +0000 | [diff] [blame] | 31 | |
| 32 | DeviceBase* GetDevice() const; |
Corentin Wallez | a594f8f | 2019-02-13 13:09:18 +0000 | [diff] [blame] | 33 | bool IsError() const; |
Corentin Wallez | 9e4518b | 2018-10-15 12:54:30 +0000 | [diff] [blame] | 34 | |
Rafael Cintron | c64242d | 2020-04-06 18:20:02 +0000 | [diff] [blame] | 35 | protected: |
| 36 | ~ObjectBase() override = default; |
| 37 | |
Corentin Wallez | 9e4518b | 2018-10-15 12:54:30 +0000 | [diff] [blame] | 38 | private: |
| 39 | DeviceBase* mDevice; |
Corentin Wallez | 9e4518b | 2018-10-15 12:54:30 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | } // namespace dawn_native |
| 43 | |
| 44 | #endif // DAWNNATIVE_OBJECTBASE_H_ |