13f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan/* 2cc366e573e31f43a6101fd6e04b90c6afdc3b7a7Stephen Hines * Copyright 2010-2012, The Android Open Source Project 33f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * 43f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * Licensed under the Apache License, Version 2.0 (the "License"); 53f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * you may not use this file except in compliance with the License. 63f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * You may obtain a copy of the License at 73f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * 83f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * http://www.apache.org/licenses/LICENSE-2.0 93f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * 103f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * Unless required by applicable law or agreed to in writing, software 113f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * distributed under the License is distributed on an "AS IS" BASIS, 123f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 133f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * See the License for the specific language governing permissions and 143f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan * limitations under the License. 153f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan */ 163f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan 17c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#ifndef BCC_SCRIPT_H 18c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#define BCC_SCRIPT_H 19eaa0cc3412cdbda8f81476aac15d5cea40b43206Logan 203f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logannamespace bcc { 21071288a0a3bbc3c4a6e161ea7474a5c06bd15ae0Stephen Hines 22ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Changclass Source; 235e3e0ce19d80c9a42b89ca95f22d98fbbe6ffb14Shih-wei Liao 24ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Changclass Script { 25ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Changprivate: 26ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // This is the source associated with this object and is going to be 27ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // compiled. 28ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang Source *mSource; 2902286cbd7505ed355cb9b301326db51639789049Logan 30ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Changprotected: 31ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // This hook will be invoked after the script object is successfully reset. 32ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang virtual bool doReset() 33ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang { return true; } 343f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan 35ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Changpublic: 36ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang Script(Source &pSource) : mSource(&pSource) { } 37eaa0cc3412cdbda8f81476aac15d5cea40b43206Logan 38ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang virtual ~Script() { } 393f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan 40ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // Reset this object with the new source supplied. Return false if this 41ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // object remains unchanged after the call (e.g., the supplied source is 42ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // the same with the one contain in this object.) If pPreserveCurrent is 43ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // false, the current containing source will be destroyed after successfully 44ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // reset. 45ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang bool reset(Source &pSource, bool pPreserveCurrent = false); 46033f46ea98d154040fbfcf9ee844f09e6aceebc6Logan 47ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // Merge (or link) another source into the current source associated with 48ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // this Script object. Return false on error. 49ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // 50ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang // This is equivalent to the call to Script::merge(...) on mSource. 51ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang bool mergeSource(Source &pSource, bool pPreserveSource = false); 520e56786df8c1d4828798f91fe2bf850d414ee04fStephen Hines 53ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang inline Source &getSource() 54ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang { return *mSource; } 55ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang inline const Source &getSource() const 56ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang { return *mSource; } 57ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang}; 583f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan 59ccc39a8f412edaec2d231ed1ec70ff25fa83af37Zonr Chang} // end namespace bcc 603f3d31fc9eac3d82ed9d04690aafb58f1715b8d8Logan 61c72c4ddfcd79c74f70713da91a69569451b5c19eZonr Chang#endif // BCC_SCRIPT_H 62