blob: aaa5ebaffb0125c225295ec29845a5209156e6cc [file] [log] [blame]
Logan3f3d31f2010-11-27 13:52:03 +08001/*
Stephen Hinescc366e52012-02-21 17:22:04 -08002 * Copyright 2010-2012, The Android Open Source Project
Logan3f3d31f2010-11-27 13:52:03 +08003 *
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 Hines2f6a4932012-05-03 12:27:13 -070017#ifndef BCC_EXECUTION_ENGINE_SCRIPT_H
18#define BCC_EXECUTION_ENGINE_SCRIPT_H
Loganeaa0cc32010-12-29 01:04:20 +080019
Logan3f3d31f2010-11-27 13:52:03 +080020namespace bcc {
Logancf3e5212010-12-29 01:44:55 +080021
Zonr Chang19218c02012-04-05 10:44:53 +080022class Source;
Logan3f3d31f2010-11-27 13:52:03 +080023
Zonr Chang19218c02012-04-05 10:44:53 +080024class Script {
25private:
26 // This is the source associated with this object and is going to be
27 // compiled.
28 Source *mSource;
Zonr Chang4ea08862012-01-17 17:26:49 +080029
Zonr Chang19218c02012-04-05 10:44:53 +080030protected:
31 // This hook will be invoked after the script object is succssfully reset
32 // itself.
33 virtual bool doReset()
34 { return true; }
Logan39736412010-12-29 00:24:04 +080035
Zonr Chang19218c02012-04-05 10:44:53 +080036public:
37 Script(Source &pSource) : mSource(&pSource) { }
Logancf3e5212010-12-29 01:44:55 +080038
Zonr Chang19218c02012-04-05 10:44:53 +080039 virtual ~Script() { }
Logancf3e5212010-12-29 01:44:55 +080040
Zonr Chang19218c02012-04-05 10:44:53 +080041 // 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 Chang4ea08862012-01-17 17:26:49 +080047
Zonr Chang19218c02012-04-05 10:44:53 +080048 // 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 Chang4ea08862012-01-17 17:26:49 +080053
Zonr Chang19218c02012-04-05 10:44:53 +080054 inline Source &getSource()
55 { return *mSource; }
56 inline const Source &getSource() const
57 { return *mSource; }
58};
Loganecf4cbd2011-01-06 05:34:11 +080059
Zonr Chang19218c02012-04-05 10:44:53 +080060} // end namespace bcc
Logan42598052011-01-26 22:41:13 +080061
Stephen Hines2f6a4932012-05-03 12:27:13 -070062#endif // BCC_EXECUTION_ENGINE_SCRIPT_H