2010-05-20 18:58:17 +02:00
/* -------------------------------------------------------------------------- */
2017-05-25 16:07:35 +02:00
/* Copyright 2002-2017, OpenNebula Project, OpenNebula Systems */
2010-05-20 18:58:17 +02: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 IMAGE_TEMPLATE_H_
# define IMAGE_TEMPLATE_H_
2010-08-03 16:22:48 +02:00
# include "Template.h"
2010-05-20 18:58:17 +02:00
using namespace std ;
/**
2011-10-11 00:20:50 +02:00
* Image Template class , it represents the attributes of an Image
2010-05-20 18:58:17 +02:00
*/
2010-08-03 16:22:48 +02:00
class ImageTemplate : public Template
2010-05-20 18:58:17 +02:00
{
public :
2010-08-03 16:22:48 +02:00
ImageTemplate ( ) : Template ( true , ' = ' , " TEMPLATE " ) { } ;
2010-05-20 18:58:17 +02:00
2012-06-12 18:59:23 +02:00
ImageTemplate ( const ImageTemplate & tmpl ) : Template ( tmpl ) { } ;
2012-05-25 12:56:51 +02:00
2010-05-20 18:58:17 +02:00
~ ImageTemplate ( ) { } ;
2012-01-20 17:45:14 +01:00
/**
* Checks the template for RESTRICTED ATTRIBUTES
* @ param rs_attr the first restricted attribute found if any
* @ return true if a restricted attribute is found in the template
*/
bool check ( string & rs_attr )
{
return Template : : check ( rs_attr , restricted_attributes ) ;
} ;
2012-01-23 08:18:12 -08:00
2014-09-03 11:36:46 +02:00
/**
* Deletes all restricted attributes
*/
void remove_restricted ( )
{
Template : : remove_restricted ( restricted_attributes ) ;
} ;
/**
* Deletes all the attributes , except the restricted ones
*/
void remove_all_except_restricted ( )
{
Template : : remove_all_except_restricted ( restricted_attributes ) ;
} ;
2015-06-10 19:56:35 +02:00
bool is_saving ( )
2013-03-01 19:04:56 +01:00
{
2015-06-09 23:25:10 +02:00
bool save_as_hot ;
2012-03-05 23:49:18 +01:00
2015-06-09 23:25:10 +02:00
get ( " SAVE_AS_HOT " , save_as_hot ) ;
2012-03-05 23:49:18 +01:00
2015-06-09 23:25:10 +02:00
return save_as_hot ;
2012-03-05 23:49:18 +01:00
}
2015-06-10 19:56:35 +02:00
void set_saving ( )
2013-03-01 19:04:56 +01:00
{
2015-06-09 23:25:10 +02:00
replace ( " SAVE_AS_HOT " , " YES " ) ;
2012-03-05 23:49:18 +01:00
}
2012-01-23 08:18:12 -08:00
private :
friend class ImagePool ;
static vector < string > restricted_attributes ;
2014-10-06 16:57:40 +02:00
bool has_restricted ( )
{
return restricted_attributes . size ( ) > 0 ;
} ;
2012-01-24 03:00:57 -08:00
/**
* Stores the attributes as restricted , these attributes will be used in
* ImageTemplate : : check
* @ param rattrs Attributes to restrict
*/
2016-02-04 13:10:42 +01:00
static void set_restricted_attributes ( vector < const SingleAttribute * > & rattrs )
2012-01-24 03:00:57 -08:00
{
Template : : set_restricted_attributes ( rattrs , restricted_attributes ) ;
} ;
2010-05-20 18:58:17 +02:00
} ;
2013-03-07 22:44:18 +01:00
2010-05-20 18:58:17 +02:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
# endif /*IMAGE_TEMPLATE_H_*/