2012-11-26 15:48:10 +04:00
/* -------------------------------------------------------------------------- */
2016-05-04 13:33:23 +03:00
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems */
2012-11-26 15:48:10 +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 DEFAULT_QUOTAS_H_
# define DEFAULT_QUOTAS_H_
# include "Quotas.h"
2012-11-26 21:14:12 +04:00
# include "SqlDB.h"
# include "ObjectSQL.h"
2012-11-26 15:48:10 +04:00
2012-11-30 05:59:26 +04:00
class DefaultQuotas : public Quotas
2012-11-26 15:48:10 +04:00
{
public :
2012-11-26 19:12:05 +04:00
DefaultQuotas (
const char * _root_elem ,
const char * _ds_xpath ,
const char * _net_xpath ,
const char * _img_xpath ,
const char * _vm_xpath ) :
2012-11-30 03:16:52 +04:00
Quotas ( _ds_xpath , _net_xpath , _img_xpath , _vm_xpath , true ) ,
2012-11-26 19:12:05 +04:00
root_elem ( _root_elem )
2012-11-30 03:16:52 +04:00
{ } ;
2012-11-26 15:48:10 +04:00
2012-11-29 20:26:21 +04:00
~ DefaultQuotas ( ) { } ;
2012-11-26 19:12:05 +04:00
/**
* Generates a string representation of the quotas in XML format
* @ param xml the string to store the XML
* @ return the same xml string to use it in < < compounds
*/
string & to_xml ( string & xml ) const ;
2012-11-26 21:14:12 +04:00
/**
* Writes the quotas in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
2012-11-30 05:59:26 +04:00
int insert ( ) ;
2012-11-26 21:14:12 +04:00
/**
* Writes / updates the quotas data fields in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
2012-11-30 05:59:26 +04:00
int update ( ) ;
2012-11-26 21:14:12 +04:00
/**
* Reads the Quotas from the database .
* @ param db pointer to the db
* @ return 0 on success
*/
2012-11-30 05:59:26 +04:00
int select ( ) ;
2012-11-26 21:14:12 +04:00
private :
/**
2012-11-30 05:59:26 +04:00
* Name for the default quota attribute
2012-11-26 21:14:12 +04:00
*/
2012-11-30 05:59:26 +04:00
const char * root_elem ;
2012-11-26 21:14:12 +04:00
2012-11-26 19:12:05 +04:00
/**
* Builds quota object from an ObjectXML
* @ param xml The xml - formatted string
2012-11-26 21:14:12 +04:00
* @ return 0 on success
2012-11-26 19:12:05 +04:00
*/
int from_xml ( const string & xml ) ;
2012-11-26 15:48:10 +04:00
} ;
# endif /*DEFAULT_QUOTAS_H_*/