blob: c64dbf6e506f95072d82c2fd525317f990fe650c [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,
29 EX_VAR
30 };
31
Zonr Changb2573012010-10-07 19:35:21 +080032 private:
Zonr Chang641558f2010-10-12 21:07:06 +080033 RSContext *mContext;
34
Zonr Changa41ce1d2010-10-06 02:23:12 +080035 Kind mK;
36
Zonr Changb2573012010-10-07 19:35:21 +080037 protected:
Zonr Chang641558f2010-10-12 21:07:06 +080038 RSExportable(RSContext *Context, RSExportable::Kind K)
39 : mContext(Context),
40 mK(K) {
Zonr Changa41ce1d2010-10-06 02:23:12 +080041 Context->newExportable(this);
42 return;
43 }
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();
Zonr Chang641558f2010-10-12 21:07:06 +080053 inline bool isKeep() const { return (mContext == NULL); }
54
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};
Zonr Changa41ce1d2010-10-06 02:23:12 +080061}
62
Stephen Hinese639eb52010-11-08 19:27:20 -080063#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_RS_EXPORTABLE_H_ NOLINT