/* -------------------------------------------------------------------------- */ /* Copyright 2002-2021, OpenNebula Project, OpenNebula Systems */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); you may */ /* not use this file except in compliance with the License. You may obtain */ /* a copy of the License at */ /* */ /* http://www.apache.org/licenses/LICENSE-2.0 */ /* */ /* Unless required by applicable law or agreed to in writing, software */ /* distributed under the License is distributed on an "AS IS" BASIS, */ /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ /* See the License for the specific language governing permissions and */ /* limitations under the License. */ /* -------------------------------------------------------------------------- */ #ifndef HOOK_H_ #define HOOK_H_ #include #include "Template.h" #include "PoolObjectSQL.h" #include "NebulaUtil.h" class HookImplementation; class Hook : public PoolObjectSQL { public: ~Hook(); /** * Defines the hook type, so a whole hook class can be masked */ enum HookType { STATE = 0x01, API = 0x02, UNDEFINED = 0x04 }; static std::string hook_type_to_str(HookType ht) { switch(ht) { case STATE: return "state"; case API: return "api"; case UNDEFINED: return ""; } return ""; }; static HookType str_to_hook_type(std::string& ht) { one_util::tolower(ht); if (ht == "state") { return STATE; } else if (ht == "api") { return API; } return UNDEFINED; } /** * Function to print the Hook object into a string in XML format * @param xml the resulting XML string * @return a reference to the generated string */ std::string& to_xml(std::string& xml) const { return _to_xml(xml, false); } /** * Include exection records for the hook */ std::string& to_xml_extended(std::string& xml) const { return _to_xml(xml, true); } private: friend class HookPool; // ************************************************************************* // Constructor/Destructor // ************************************************************************* Hook(std::unique_ptr