2010-05-20 20:58:17 +04:00
/* ------------------------------------------------------------------------ */
2013-01-24 19:18:30 +04:00
/* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs */
2010-05-20 20:58:17 +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 IMAGE_H_
# define IMAGE_H_
# include "PoolSQL.h"
# include "ImageTemplate.h"
2010-06-30 15:10:07 +04:00
# include "NebulaLog.h"
2012-10-25 03:32:35 +04:00
# include "ObjectCollection.h"
2010-05-20 20:58:17 +04:00
using namespace std ;
/**
* The Image class .
*/
class Image : public PoolObjectSQL
{
public :
/**
* Type of Images
*/
2010-06-24 18:12:45 +04:00
enum ImageType
{
OS = 0 , /** < Base OS image */
CDROM = 1 , /** < An ISO9660 image */
2012-11-16 14:29:52 +04:00
DATABLOCK = 2 , /** < User persistent data device */
2012-12-05 19:48:56 +04:00
KERNEL = 3 , /** < Kernel files */
RAMDISK = 4 , /** < Initrd files */
CONTEXT = 5 /** < Context files */
2010-06-24 18:12:45 +04:00
} ;
2012-03-06 02:49:18 +04:00
/**
* Return the string representation of an ImageType
* @ param ob the type
* @ return the string
2012-10-25 03:32:35 +04:00
*/
2012-03-06 02:49:18 +04:00
static string type_to_str ( ImageType ob )
{
switch ( ob )
{
case OS : return " OS " ; break ;
case CDROM : return " CDROM " ; break ;
case DATABLOCK : return " DATABLOCK " ; break ;
2012-12-05 02:19:08 +04:00
case KERNEL : return " KERNEL " ; break ;
case RAMDISK : return " RAMDISK " ; break ;
case CONTEXT : return " CONTEXT " ; break ;
2012-03-06 02:49:18 +04:00
default : return " " ;
}
} ;
2012-06-01 21:18:49 +04:00
/**
* Return the string representation of an ImageType
* @ param ob the type
* @ return the string
2012-10-25 03:32:35 +04:00
*/
static ImageType str_to_type ( string & str_type ) ;
2012-06-01 21:18:49 +04:00
2012-04-19 13:44:19 +04:00
/**
2012-10-25 03:32:35 +04:00
* Type of Disks ( used by the VMM_MAD ) . Values : BLOCK , CDROM or
2012-04-19 13:44:19 +04:00
* FILE
*/
enum DiskType
{
2013-10-08 20:51:54 +04:00
FILE = 0 , /** < File-based disk */
CD_ROM = 1 , /** < An ISO9660 disk */
BLOCK = 2 , /** < Block-device disk */
RBD = 3 , /** < CEPH RBD disk */
RBD_CDROM = 4 , /** < CEPH RBD CDROM disk */
2013-11-03 21:03:39 +04:00
GLUSTER = 5 , /** < Gluster Block Device */
NONE = 255 /** < No disk type, error situation */
2012-04-19 13:44:19 +04:00
} ;
/**
* Return the string representation of a DiskType
* @ param ob the type
* @ return the string
2012-10-25 03:32:35 +04:00
*/
2012-04-19 13:44:19 +04:00
static string disk_type_to_str ( DiskType ob )
{
switch ( ob )
{
2013-10-08 20:51:54 +04:00
case FILE : return " FILE " ; break ;
case CD_ROM : return " CDROM " ; break ;
case BLOCK : return " BLOCK " ; break ;
case RBD : return " RBD " ; break ;
case RBD_CDROM : return " RBD_CDROM " ; break ;
case GLUSTER : return " GLUSTER " ; break ;
default : return " " ;
2012-04-19 13:44:19 +04:00
}
} ;
2013-10-02 18:21:46 +04:00
/**
* Return the string representation of a DiskType
* @ param s_disk_type string representing the DiskTypr
* @ return the DiskType ( defaults to FILE )
*/
static DiskType str_to_disk_type ( string & s_disk_type ) ;
2010-06-24 18:12:45 +04:00
/**
* Image State
*/
enum ImageState
{
INIT = 0 , /** < Initialization state */
2010-07-21 19:50:04 +04:00
READY = 1 , /** < Image ready to use */
USED = 2 , /** < Image in use */
2011-03-22 20:21:09 +03:00
DISABLED = 3 , /** < Image can not be instantiated by a VM */
LOCKED = 4 , /** < FS operation for the Image in process */
2012-06-12 20:59:23 +04:00
ERROR = 5 , /** < Error state the operation FAILED*/
CLONE = 6 , /** < Image is being cloned */
DELETE = 7 , /** < DS is deleting the image */
USED_PERS = 8 /** < Image is in use and persistent */
2010-06-24 18:12:45 +04:00
} ;
2012-05-25 14:56:51 +04:00
/**
* Returns the string representation of an ImageState
* @ param state The state
* @ return the string representation
*/
static string state_to_str ( ImageState state )
{
switch ( state )
{
case INIT : return " INIT " ; break ;
case READY : return " READY " ; break ;
case USED : return " USED " ; break ;
case DISABLED : return " DISABLED " ; break ;
case LOCKED : return " LOCKED " ; break ;
case ERROR : return " ERROR " ; break ;
2012-06-12 20:59:23 +04:00
case CLONE : return " CLONE " ; break ;
case DELETE : return " DELETE " ; break ;
case USED_PERS : return " USED " ; break ;
2012-05-25 14:56:51 +04:00
default : return " " ;
}
} ;
2010-05-20 20:58:17 +04:00
// *************************************************************************
2010-05-28 20:56:35 +04:00
// Image Public Methods
2010-05-20 20:58:17 +04:00
// *************************************************************************
2010-05-28 20:56:35 +04:00
/**
* Function to print the Image object into a string in XML format
* @ param xml the resulting XML string
* @ return a reference to the generated string
*/
string & to_xml ( string & xml ) const ;
2010-05-20 20:58:17 +04:00
/**
2011-02-25 21:02:29 +03:00
* Rebuilds the object from an xml formatted string
* @ param xml_str The xml - formatted string
*
* @ return 0 on success , - 1 otherwise
2010-05-20 20:58:17 +04:00
*/
2011-02-25 21:02:29 +03:00
int from_xml ( const string & xml_str ) ;
2010-06-24 18:12:45 +04:00
2010-08-03 21:22:13 +04:00
/**
* Returns true if the image is persistent
* @ return true if the image is persistent
*/
2011-10-11 18:05:32 +04:00
bool isPersistent ( ) const
2010-08-03 21:22:13 +04:00
{
return ( persistent_img = = 1 ) ;
} ;
2010-05-28 20:56:35 +04:00
2011-03-24 18:37:15 +03:00
/**
* Returns the source path of the image
* @ return source of image
*/
2011-10-11 18:05:32 +04:00
const string & get_source ( ) const
2011-03-24 18:37:15 +03:00
{
return source ;
}
2011-10-11 18:05:32 +04:00
/**
* Returns the original path of the image
* @ return path of image
*/
const string & get_path ( ) const
{
return path ;
}
/**
* Returns the fs_type for the image ( defined for datablocks )
* @ return fs_type
*/
const string & get_fstype ( ) const
{
return fs_type ;
}
/**
2012-10-25 03:32:35 +04:00
* Returns the size of the image
2013-10-17 14:35:19 +04:00
* @ return size in MB
2011-10-11 18:05:32 +04:00
*/
2013-10-17 14:35:19 +04:00
long long get_size ( ) const
2011-10-11 18:05:32 +04:00
{
return size_mb ;
}
2011-05-07 04:49:07 +04:00
/**
2011-08-31 18:21:18 +04:00
* Sets the source path of the image
2011-05-07 04:49:07 +04:00
*/
void set_source ( const string & _source )
{
source = _source ;
}
2011-08-31 18:21:18 +04:00
/**
* Sets the size for the image
*/
2013-10-17 14:35:19 +04:00
void set_size ( long long _size_mb )
2011-08-31 18:21:18 +04:00
{
size_mb = _size_mb ;
}
2011-03-24 20:27:19 +03:00
/**
* Returns the type of the image
* @ return type
*/
2012-06-12 20:59:23 +04:00
ImageType get_type ( ) const
2011-03-24 20:27:19 +03:00
{
return type ;
}
2010-05-25 20:19:22 +04:00
/**
2011-03-22 20:21:09 +03:00
* Returns the image state
* @ return state of image
2010-06-24 18:12:45 +04:00
*/
2012-05-25 14:56:51 +04:00
ImageState get_state ( ) const
2010-05-25 20:19:22 +04:00
{
2011-03-22 20:21:09 +03:00
return state ;
2010-05-25 20:19:22 +04:00
}
2010-05-20 20:58:17 +04:00
/**
2011-03-22 20:21:09 +03:00
* Sets the image state
* @ param state of image
2010-05-21 21:02:08 +04:00
*/
2011-03-22 20:21:09 +03:00
void set_state ( ImageState _state )
{
state = _state ;
}
2010-05-28 20:56:35 +04:00
2011-03-22 20:21:09 +03:00
/**
2012-06-12 20:59:23 +04:00
* Return the ID of the image we are cloning this one from ( if any )
2011-03-22 20:21:09 +03:00
*/
2012-06-12 20:59:23 +04:00
int get_cloning_id ( ) const
2011-03-22 20:21:09 +03:00
{
2012-06-12 20:59:23 +04:00
return cloning_id ;
2011-03-22 20:21:09 +03:00
}
2010-05-21 21:02:08 +04:00
/**
2012-06-12 20:59:23 +04:00
* Sets the ID of the image we are cloning this one from ( if any )
2010-05-20 20:58:17 +04:00
*/
2012-06-12 20:59:23 +04:00
void set_cloning_id ( int id )
2011-03-22 20:21:09 +03:00
{
2012-06-12 20:59:23 +04:00
cloning_id = id ;
2011-03-22 20:21:09 +03:00
}
2010-05-28 20:56:35 +04:00
2011-03-25 02:11:10 +03:00
/**
2012-06-12 20:59:23 +04:00
* Clear the cloning state of the image
2011-03-25 02:11:10 +03:00
*/
2012-06-12 20:59:23 +04:00
void clear_cloning_id ( )
2011-03-25 02:11:10 +03:00
{
2012-06-12 20:59:23 +04:00
cloning_id = - 1 ;
2012-10-25 03:32:35 +04:00
}
2012-06-12 20:59:23 +04:00
/* ---------------------------------------------------------------------- */
2012-10-19 14:52:57 +04:00
/* Access Image Counters (running vms and cloning operations ) */
2012-06-12 20:59:23 +04:00
/* ---------------------------------------------------------------------- */
2011-03-25 02:11:10 +03:00
2012-10-25 03:32:35 +04:00
int dec_running ( int vm_id )
2012-05-25 14:56:51 +04:00
{
2012-10-25 03:32:35 +04:00
if ( vm_collection . del_collection_id ( vm_id ) = = 0 )
{
running_vms - - ;
}
return running_vms ;
2012-05-25 14:56:51 +04:00
}
2012-10-25 03:32:35 +04:00
int inc_running ( int vm_id )
2012-05-25 14:56:51 +04:00
{
2012-10-25 03:32:35 +04:00
if ( vm_collection . add_collection_id ( vm_id ) = = 0 )
{
running_vms + + ;
}
return running_vms ;
2012-05-25 14:56:51 +04:00
}
2012-06-12 20:59:23 +04:00
int get_running ( ) const
2012-05-25 14:56:51 +04:00
{
2011-03-25 02:11:10 +03:00
return running_vms ;
2012-05-25 14:56:51 +04:00
}
2012-06-12 20:59:23 +04:00
int get_cloning ( ) const
2012-05-25 14:56:51 +04:00
{
2012-06-12 20:59:23 +04:00
return cloning_ops ;
2012-05-25 14:56:51 +04:00
}
2012-10-31 20:50:16 +04:00
int dec_cloning ( int img_id )
2012-05-25 14:56:51 +04:00
{
2012-10-31 20:50:16 +04:00
if ( img_clone_collection . del_collection_id ( img_id ) = = 0 )
{
cloning_ops - - ;
}
return cloning_ops ;
2012-05-25 14:56:51 +04:00
}
2012-10-31 20:50:16 +04:00
int inc_cloning ( int img_id )
2012-05-25 14:56:51 +04:00
{
2012-10-31 20:50:16 +04:00
if ( img_clone_collection . add_collection_id ( img_id ) = = 0 )
{
cloning_ops + + ;
}
return cloning_ops ;
2012-05-25 14:56:51 +04:00
}
2010-06-24 18:22:05 +04:00
/**
2011-10-21 20:50:04 +04:00
* Sets the Image type .
*
* @ param _type the new type . It will be transformed to upper case
* @ return 0 on success , - 1 otherwise
2010-06-24 18:22:05 +04:00
*/
2011-10-21 20:50:04 +04:00
int set_type ( string & _type ) ;
2010-06-24 18:22:05 +04:00
2012-01-06 04:36:57 +04:00
/**
* Check if the image can be used by other users
* @ return true if group or others can access the image
*/
bool isPublic ( )
{
2012-10-25 03:32:35 +04:00
return ( group_u = = 1 | | other_u = = 1 ) ;
2012-01-06 04:36:57 +04:00
}
2012-03-06 02:49:18 +04:00
/**
* Check if the image is used for saving_as a current one
* @ return true if the image will be used to save an existing image .
*/
bool isSaving ( )
{
ImageTemplate * it = static_cast < ImageTemplate * > ( obj_template ) ;
return it - > is_saving ( ) ;
}
2013-03-01 22:04:56 +04:00
/**
* Check if the image is a hot snapshot
* @ return true if image is a hot snapshot
*/
bool isHot ( )
{
ImageTemplate * it = static_cast < ImageTemplate * > ( obj_template ) ;
2013-03-08 01:44:18 +04:00
return it - > is_saving_hot ( ) ;
2013-03-01 22:04:56 +04:00
}
2012-01-06 04:36:57 +04:00
/**
* Set permissions for the Image . Extends the PoolSQLObject method
* by checking the persistent state of the image .
*/
int set_permissions ( int _owner_u ,
int _owner_m ,
int _owner_a ,
int _group_u ,
int _group_m ,
int _group_a ,
int _other_u ,
int _other_m ,
int _other_a ,
string & error_str )
{
if ( isPersistent ( ) & & ( _group_u = = 1 | | _other_u = = 1 ) )
{
error_str = " Image cannot be public and persistent. " ;
return - 1 ;
2012-10-25 03:32:35 +04:00
}
2012-01-06 04:36:57 +04:00
return PoolObjectSQL : : set_permissions ( _owner_u , _owner_m , _owner_a ,
_group_u , _group_m , _group_a ,
_other_u , _other_m , _other_a ,
error_str ) ;
} ;
2010-08-03 21:22:13 +04:00
/**
2010-08-30 20:21:21 +04:00
* Set / Unset an image as persistent
* @ param persistent true to make an image persistent
2011-07-26 21:35:58 +04:00
* @ param error_str Returns the error reason , if any
*
2010-08-05 21:28:28 +04:00
* @ return 0 on success
2010-08-03 21:22:13 +04:00
*/
2011-07-26 21:35:58 +04:00
int persistent ( bool persis , string & error_str )
2010-08-03 21:22:13 +04:00
{
2012-10-30 21:37:37 +04:00
ostringstream oss ;
2012-10-25 03:32:35 +04:00
2012-10-30 21:37:37 +04:00
switch ( state )
2010-08-03 21:22:13 +04:00
{
2012-10-30 21:37:37 +04:00
case USED :
case CLONE :
case USED_PERS :
goto error_state ;
break ;
case INIT :
case READY :
case DISABLED :
case LOCKED :
case ERROR :
case DELETE :
if ( persis = = true )
{
if ( isPublic ( ) )
{
goto error_public ;
}
persistent_img = 1 ;
}
else
{
persistent_img = 0 ;
}
break ;
2010-08-03 21:22:13 +04:00
}
2010-08-04 19:42:53 +04:00
2011-07-26 21:35:58 +04:00
return 0 ;
2012-10-30 21:37:37 +04:00
error_state :
oss < < " Image cannot be in state " < < state_to_str ( state ) < < " . " ;
error_str = oss . str ( ) ;
2011-07-26 21:35:58 +04:00
goto error_common ;
2012-01-06 04:36:57 +04:00
2011-07-26 21:35:58 +04:00
error_public :
2011-07-27 12:17:17 +04:00
error_str = " Image cannot be public and persistent. " ;
2011-07-26 21:35:58 +04:00
goto error_common ;
2012-01-06 04:36:57 +04:00
2011-07-26 21:35:58 +04:00
error_common :
return - 1 ;
2010-06-24 18:22:05 +04:00
}
2010-05-28 20:56:35 +04:00
/**
2010-05-31 17:08:24 +04:00
* Modifies the given disk attribute adding the following attributes :
* * SOURCE : the file - path .
2012-04-26 18:53:11 +04:00
* * TARGET : will only be set if the Image ' s definition includes it .
*
2010-06-24 20:35:18 +04:00
* @ param disk attribute for the VM template
2012-04-25 18:47:12 +04:00
* @ param img_type will be set to the used image ' s type
2012-04-26 18:53:11 +04:00
* @ param dev_prefix will be set to the defined dev_prefix ,
* or the default one
2013-11-14 14:49:53 +04:00
* @ param inherit_attrs Attributes to be inherited from the image template
* into the disk
2012-04-26 18:53:11 +04:00
*
* @ return 0 on success , - 1 otherwise
2010-05-28 20:56:35 +04:00
*/
2013-11-14 14:49:53 +04:00
int disk_attribute ( VectorAttribute * disk ,
ImageType & img_type ,
string & dev_prefix ,
const vector < string > & inherit_attrs ) ;
2010-05-20 20:58:17 +04:00
2011-06-02 01:53:09 +04:00
/**
* Factory method for image templates
*/
2012-03-06 02:49:18 +04:00
Template * get_new_template ( ) const
2011-06-02 01:53:09 +04:00
{
return new ImageTemplate ;
}
2012-02-10 22:28:18 +04:00
/**
* Returns the Datastore ID
*/
2012-03-06 02:49:18 +04:00
int get_ds_id ( ) const
2012-02-10 22:28:18 +04:00
{
return ds_id ;
} ;
2012-03-06 02:49:18 +04:00
/**
2013-09-02 14:53:54 +04:00
* Returns the Datastore name
2012-03-06 02:49:18 +04:00
*/
const string & get_ds_name ( ) const
{
return ds_name ;
} ;
2012-05-25 14:56:51 +04:00
2013-09-02 14:53:54 +04:00
/**
* Updates the Datastore name
*/
void set_ds_name ( const string & name )
{
ds_name = name ;
} ;
2012-05-25 14:56:51 +04:00
/**
2012-10-25 03:32:35 +04:00
* Clones this image template including image specific attributes : NAME ,
2012-06-12 20:59:23 +04:00
* TYPE , PATH , FSTYPE , SIZE and PERSISTENT
2012-05-25 14:56:51 +04:00
* @ param new_name Value for the NAME attribute
2012-06-12 20:59:23 +04:00
* @ return Pointer to the new tempalte 0 in case of success
2012-05-25 14:56:51 +04:00
*/
2012-06-12 20:59:23 +04:00
ImageTemplate * clone_template ( const string & new_name ) const ;
2012-05-25 14:56:51 +04:00
2010-05-20 20:58:17 +04:00
private :
// -------------------------------------------------------------------------
// Friends
// -------------------------------------------------------------------------
friend class ImagePool ;
// -------------------------------------------------------------------------
// Image Description
// -------------------------------------------------------------------------
/**
* Type of the Image
*/
2011-08-31 18:21:18 +04:00
ImageType type ;
2010-06-07 18:21:58 +04:00
2012-04-19 13:44:19 +04:00
/**
* Type for the Disk
*/
DiskType disk_type ;
2010-08-03 21:22:13 +04:00
/**
* Persistency of the Image
*/
2011-08-31 18:21:18 +04:00
int persistent_img ;
2010-06-07 18:21:58 +04:00
2010-05-20 20:58:17 +04:00
/**
* Registration time
*/
2011-08-31 18:21:18 +04:00
time_t regtime ;
2010-06-24 18:12:45 +04:00
2010-05-20 20:58:17 +04:00
/**
* Path to the image
*/
2011-08-31 18:21:18 +04:00
string source ;
2011-10-11 18:05:32 +04:00
/**
* Original Path to the image ( optional if source is given or datablock )
*/
string path ;
/**
* File system type for the image ( mandatory for datablocks )
*/
string fs_type ;
2011-08-31 18:21:18 +04:00
/**
* Size of the image in MB
*/
2013-10-17 14:35:19 +04:00
long long size_mb ;
2010-05-26 14:38:21 +04:00
2010-05-21 21:02:08 +04:00
/**
* Image state
*/
2011-08-31 18:21:18 +04:00
ImageState state ;
2010-06-24 18:12:45 +04:00
2010-05-21 21:02:08 +04:00
/**
* Number of VMs using the image
*/
2010-06-24 18:12:45 +04:00
int running_vms ;
2010-05-20 20:58:17 +04:00
2012-05-25 14:56:51 +04:00
/**
* Number of pending cloning operations
*/
int cloning_ops ;
/**
* Indicates if this Image is a clone of another one .
* Once the clone process is complete , it should be set to - 1
*/
2012-06-12 20:59:23 +04:00
int cloning_id ;
2012-05-25 14:56:51 +04:00
2012-02-10 22:28:18 +04:00
/**
* Datastore ID
*/
int ds_id ;
/**
* Datastore name
*/
string ds_name ;
2012-10-25 03:32:35 +04:00
/**
* Stores a collection with the VMs using the image
*/
ObjectCollection vm_collection ;
2012-10-31 20:50:16 +04:00
/**
* Stores a collection with the Images cloning this image
*/
ObjectCollection img_clone_collection ;
2010-05-20 20:58:17 +04:00
// *************************************************************************
// DataBase implementation (Private)
// *************************************************************************
/**
* Execute an INSERT or REPLACE Sql query .
* @ param db The SQL DB
* @ param replace Execute an INSERT or a REPLACE
2011-12-19 20:07:32 +04:00
* @ param error_str Returns the error reason , if any
2010-05-20 20:58:17 +04:00
* @ return 0 on success
2011-12-19 20:07:32 +04:00
*/
int insert_replace ( SqlDB * db , bool replace , string & error_str ) ;
2010-05-20 20:58:17 +04:00
/**
* Bootstraps the database table ( s ) associated to the Image
2011-10-10 17:14:46 +04:00
* @ return 0 on success
2010-05-20 20:58:17 +04:00
*/
2011-10-10 17:14:46 +04:00
static int bootstrap ( SqlDB * db )
2010-05-20 20:58:17 +04:00
{
ostringstream oss_image ( Image : : db_bootstrap ) ;
2011-10-10 17:14:46 +04:00
return db - > exec ( oss_image ) ;
2010-05-20 20:58:17 +04:00
} ;
2010-06-30 15:10:07 +04:00
/**
* " Encrypts " the password with SHA1 digest
* @ param password
* @ return sha1 encrypted password
*/
2011-04-07 04:01:40 +04:00
static string sha1_digest ( const string & pass ) ;
2010-06-30 15:10:07 +04:00
2010-05-20 20:58:17 +04:00
protected :
// *************************************************************************
// Constructor
// *************************************************************************
2011-05-12 19:10:35 +04:00
Image ( int uid ,
Feature #407: Add 'GID' attribute to some pool objects; change *pool.info XML-RPC flag meaning; update onedb migrator; fix tests.
* VM, VMTEMPLATE, VNET & IMAGE objects have a GID attribute, and a table column. The group id is inherited from the user creating the object, except for VMs created from Templates, that inherit the Template's group.
* The new flag meaning has been modified in src/rm sources and CLI commands for one.(vm,template,vnet,image)pool.info . It changes from
-2 all, -1 mine & public, >=0 UID
to
-3 mine, -2 all, -1 mine & group
* USER has a group, but not secondary ones. The user_pool table doesn't have a GID column, we'll deal with it later when the group-users relations are implemented.
* onedb migrator 1.rb: deleted USERNAME, and GID added.
2011-05-16 19:00:27 +04:00
int gid ,
2011-06-30 13:31:00 +04:00
const string & uname ,
const string & gname ,
2013-01-18 21:34:51 +04:00
int umask ,
2011-03-08 18:52:45 +03:00
ImageTemplate * img_template ) ;
2010-05-20 20:58:17 +04:00
virtual ~ Image ( ) ;
// *************************************************************************
// DataBase implementation
// *************************************************************************
static const char * db_names ;
static const char * db_bootstrap ;
static const char * table ;
/**
* Writes the Image in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
2010-08-05 21:28:28 +04:00
virtual int insert ( SqlDB * db , string & error_str ) ;
2010-05-20 20:58:17 +04:00
/**
* Writes / updates the Images data fields in the database .
* @ param db pointer to the db
* @ return 0 on success
*/
virtual int update ( SqlDB * db ) ;
} ;
# endif /*IMAGE_H_*/