blob: 544ce1a4bb64c9d8684c8bedb942524fedf217f3 [file] [log] [blame]
Corentin Wallez9e4518b2018-10-15 12:54:30 +00001// 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 Cintron7e8385c2020-04-20 17:36:22 +000018#include "common/RefCounted.h"
Corentin Wallez9e4518b2018-10-15 12:54:30 +000019
20namespace dawn_native {
21
22 class DeviceBase;
23
24 class ObjectBase : public RefCounted {
25 public:
Corentin Walleza594f8f2019-02-13 13:09:18 +000026 struct ErrorTag {};
27 static constexpr ErrorTag kError = {};
28
Corentin Wallez9e4518b2018-10-15 12:54:30 +000029 ObjectBase(DeviceBase* device);
Corentin Walleza594f8f2019-02-13 13:09:18 +000030 ObjectBase(DeviceBase* device, ErrorTag tag);
Corentin Wallez9e4518b2018-10-15 12:54:30 +000031
32 DeviceBase* GetDevice() const;
Corentin Walleza594f8f2019-02-13 13:09:18 +000033 bool IsError() const;
Corentin Wallez9e4518b2018-10-15 12:54:30 +000034
Rafael Cintronc64242d2020-04-06 18:20:02 +000035 protected:
36 ~ObjectBase() override = default;
37
Corentin Wallez9e4518b2018-10-15 12:54:30 +000038 private:
39 DeviceBase* mDevice;
Corentin Wallez9e4518b2018-10-15 12:54:30 +000040 };
41
42} // namespace dawn_native
43
44#endif // DAWNNATIVE_OBJECTBASE_H_