2017-05-18 17:36:26 +03:00
/* -------------------------------------------------------------------------- */
2023-01-09 14:23:19 +03:00
/* Copyright 2002-2023, OpenNebula Project, OpenNebula Systems */
2017-05-18 17:36:26 +03:00
/* */
/* 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. */
/* -------------------------------------------------------------------------- */
2019-09-09 15:43:51 +03:00
# ifndef HOOK_IMPLEMENTATION_H_
# define HOOK_IMPLEMENTATION_H_
2017-05-18 17:36:26 +03:00
# include <string>
2019-09-09 15:43:51 +03:00
class Template ;
class Hook ;
2017-05-18 17:36:26 +03:00
2019-09-09 15:43:51 +03:00
/**
* This is an abstract interface for any Hook class . It provides the
* specific logic for the Hook type . It is included by the Hook class that
* handles persistency .
*/
class HookImplementation
2017-05-18 17:36:26 +03:00
{
2019-09-09 15:43:51 +03:00
protected :
friend class Hook ;
2017-05-18 17:36:26 +03:00
2019-09-09 15:43:51 +03:00
HookImplementation ( ) = default ;
2017-05-18 17:36:26 +03:00
2019-09-09 15:43:51 +03:00
virtual ~ HookImplementation ( ) = default ;
2017-05-18 17:36:26 +03:00
2019-09-09 15:43:51 +03:00
/**
* Builds the hook from its template implementation
* @ param tmpl Template with hook attributes
* @ param error description
*
* @ return 0 on success
*/
virtual int from_template ( const Template * tmpl , std : : string & error ) = 0 ;
2017-05-18 17:36:26 +03:00
2019-09-09 15:43:51 +03:00
/**
* This function is execute custom setups after updating the hook template
* @ param tmpl updated template
* @ param error description
*
* @ return 0 on success
*/
virtual int post_update_template ( Template * tmpl , std : : string & error ) = 0 ;
2017-05-18 17:36:26 +03:00
2019-09-09 15:43:51 +03:00
/**
* This function parses the hook template upon creation
* @ param tmpl updated template
* @ param error description
*
* @ return 0 on success
*/
virtual int parse_template ( Template * tmpl , std : : string & error_str ) = 0 ;
2017-05-18 17:36:26 +03:00
} ;
# endif