2008-06-17 20:27:32 +04:00
/* -------------------------------------------------------------------------- */
2020-04-30 16:00:02 +03:00
/* Copyright 2002-2020, OpenNebula Project, OpenNebula Systems */
2008-06-17 20:27:32 +04: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. */
/* -------------------------------------------------------------------------- */
# ifndef OBJECT_SQL_H_
# define OBJECT_SQL_H_
2010-04-03 18:54:09 +04:00
# include "Callbackable.h"
2010-04-03 17:55:12 +04:00
# include "SqlDB.h"
2008-06-17 20:27:32 +04:00
/**
* ObjectSQL class . Provides a SQL backend interface , it should be implemented
* by persistent objects .
*/
2010-04-03 18:54:09 +04:00
class ObjectSQL : public Callbackable
2008-06-17 20:27:32 +04:00
{
public :
2019-09-03 17:31:51 +03:00
ObjectSQL ( ) = default ;
2008-06-17 20:27:32 +04:00
2019-09-03 17:31:51 +03:00
virtual ~ ObjectSQL ( ) = default ;
2008-06-17 20:27:32 +04:00
protected :
/**
* Reads the ObjectSQL ( identified with its OID ) from the database .
* @ param db pointer to the db
* @ return 0 on success
*/
virtual int select (
2010-04-03 17:55:12 +04:00
SqlDB * db ) = 0 ;
2008-06-17 20:27:32 +04:00
/**
* Writes the ObjectSQL in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
virtual int insert (
2010-08-05 21:28:28 +04:00
SqlDB * db ,
2020-07-02 23:42:10 +03:00
std : : string & error_str ) = 0 ;
2008-06-17 20:27:32 +04:00
/**
* Updates the ObjectSQL in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
virtual int update (
2010-04-03 17:55:12 +04:00
SqlDB * db ) = 0 ;
2008-06-17 20:27:32 +04:00
/**
* Removes the ObjectSQL from the database .
* @ param db pointer to the db
* @ return 0 on success
*/
virtual int drop (
2010-04-03 17:55:12 +04:00
SqlDB * db ) = 0 ;
2008-06-17 20:27:32 +04:00
} ;
2010-09-02 22:44:14 +04:00
# endif /*OBJECT_SQL_H_*/