blob: 0871be3024b426e28cc047f311e0ce2c350514b0 [file] [log] [blame]
Zonr Changc383a502010-10-12 01:52:08 +08001/*
2 * Copyright 2010, 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
Stephen Hinese639eb52010-11-08 19:27:20 -080017#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORTABLE_H_ // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORTABLE_H_
Zonr Changa41ce1d2010-10-06 02:23:12 +080019
20#include "slang_rs_context.h"
21
22namespace slang {
23
24class RSExportable {
Zonr Changb2573012010-10-07 19:35:21 +080025 public:
Zonr Changa41ce1d2010-10-06 02:23:12 +080026 enum Kind {
27 EX_FUNC,
28 EX_TYPE,
Stephen Hines593a8942011-05-10 15:29:50 -070029 EX_VAR,
30 EX_FOREACH
Zonr Changa41ce1d2010-10-06 02:23:12 +080031 };
32
Zonr Changb2573012010-10-07 19:35:21 +080033 private:
Zonr Chang641558f2010-10-12 21:07:06 +080034 RSContext *mContext;
35
Zonr Changa41ce1d2010-10-06 02:23:12 +080036 Kind mK;
37
Zonr Changb2573012010-10-07 19:35:21 +080038 protected:
Zonr Chang641558f2010-10-12 21:07:06 +080039 RSExportable(RSContext *Context, RSExportable::Kind K)
40 : mContext(Context),
41 mK(K) {
Zonr Changa41ce1d2010-10-06 02:23:12 +080042 Context->newExportable(this);
Zonr Changa41ce1d2010-10-06 02:23:12 +080043 }
44
Zonr Changb2573012010-10-07 19:35:21 +080045 public:
Zonr Changa41ce1d2010-10-06 02:23:12 +080046 inline Kind getKind() const { return mK; }
47
Zonr Chang641558f2010-10-12 21:07:06 +080048 // When keep() is invoked, mKeep will set to true and the associated RSContext
49 // won't free this RSExportable object in its destructor. The deallcation
50 // responsibility is then transferred to the object who invoked this function.
Zonr Chang3cd3dd32010-10-22 02:11:35 +080051 // Return false if the exportable is kept or failed to keep.
52 virtual bool keep();
Chris Wailes5abbe0e2014-08-12 15:58:29 -070053 inline bool isKeep() const { return (mContext == nullptr); }
Zonr Chang641558f2010-10-12 21:07:06 +080054
55 virtual bool equals(const RSExportable *E) const;
56
57 inline RSContext *getRSContext() const { return mContext; }
58
Zonr Changa41ce1d2010-10-06 02:23:12 +080059 virtual ~RSExportable() { }
60};
Stephen Hinese67239d2012-02-24 15:08:36 -080061} // namespace slang
Zonr Changa41ce1d2010-10-06 02:23:12 +080062
Stephen Hinese639eb52010-11-08 19:27:20 -080063#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORTABLE_H_ NOLINT