Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 1 | /* |
Stephen Hines | cc366e5 | 2012-02-21 17:22:04 -0800 | [diff] [blame] | 2 | * Copyright 2010-2012, The Android Open Source Project |
Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 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 Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 17 | #ifndef BCC_EXECUTION_ENGINE_SCRIPT_H |
| 18 | #define BCC_EXECUTION_ENGINE_SCRIPT_H |
Logan | eaa0cc3 | 2010-12-29 01:04:20 +0800 | [diff] [blame] | 19 | |
Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 20 | namespace bcc { |
Logan | cf3e521 | 2010-12-29 01:44:55 +0800 | [diff] [blame] | 21 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 22 | class Source; |
Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 23 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 24 | class Script { |
| 25 | private: |
| 26 | // This is the source associated with this object and is going to be |
| 27 | // compiled. |
| 28 | Source *mSource; |
Zonr Chang | 4ea0886 | 2012-01-17 17:26:49 +0800 | [diff] [blame] | 29 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 30 | protected: |
| 31 | // This hook will be invoked after the script object is succssfully reset |
| 32 | // itself. |
| 33 | virtual bool doReset() |
| 34 | { return true; } |
Logan | 3973641 | 2010-12-29 00:24:04 +0800 | [diff] [blame] | 35 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 36 | public: |
| 37 | Script(Source &pSource) : mSource(&pSource) { } |
Logan | cf3e521 | 2010-12-29 01:44:55 +0800 | [diff] [blame] | 38 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 39 | virtual ~Script() { } |
Logan | cf3e521 | 2010-12-29 01:44:55 +0800 | [diff] [blame] | 40 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 41 | // Reset this object with the new source supplied. Return false if this |
| 42 | // object remains unchanged after the call (e.g., the supplied source is |
| 43 | // the same with the one contain in this object.) If pPreserveCurrent is |
| 44 | // false, the current containing source will be destroyed after successfully |
| 45 | // reset. |
| 46 | bool reset(Source &pSource, bool pPreserveCurrent = false); |
Zonr Chang | 4ea0886 | 2012-01-17 17:26:49 +0800 | [diff] [blame] | 47 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 48 | // Merge (or link) another source into the current source associated with |
| 49 | // this Script object. Return false on error. |
| 50 | // |
| 51 | // This is equivalent to the call to Script::merge(...) on mSource. |
| 52 | bool mergeSource(Source &pSource, bool pPreserveSource = false); |
Zonr Chang | 4ea0886 | 2012-01-17 17:26:49 +0800 | [diff] [blame] | 53 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 54 | inline Source &getSource() |
| 55 | { return *mSource; } |
| 56 | inline const Source &getSource() const |
| 57 | { return *mSource; } |
| 58 | }; |
Logan | ecf4cbd | 2011-01-06 05:34:11 +0800 | [diff] [blame] | 59 | |
Zonr Chang | 19218c0 | 2012-04-05 10:44:53 +0800 | [diff] [blame] | 60 | } // end namespace bcc |
Logan | 4259805 | 2011-01-26 22:41:13 +0800 | [diff] [blame] | 61 | |
Stephen Hines | 2f6a493 | 2012-05-03 12:27:13 -0700 | [diff] [blame] | 62 | #endif // BCC_EXECUTION_ENGINE_SCRIPT_H |