SQLStorage Class Reference

#include <sql_storage.h>

Inheritance diagram for SQLStorage:
Storage Singleton< Storage > zmm::Object

Data Structures

class  AddUpdateTable
class  ChangedContainersStr

Public Member Functions

virtual zmm::String quote (zmm::String str)=0
virtual zmm::String quote (int val)=0
virtual zmm::String quote (unsigned int val)=0
virtual zmm::String quote (long val)=0
virtual zmm::String quote (unsigned long val)=0
virtual zmm::String quote (bool val)=0
virtual zmm::String quote (char val)=0
virtual zmm::Ref< SQLResultselect (const char *query, int length)=0
virtual int exec (const char *query, int length, bool getLastInsertId=false)=0
void dbReady ()
zmm::Ref< SQLResultselect (zmm::Ref< zmm::StringBuffer > buf)
int exec (zmm::Ref< zmm::StringBuffer > buf, bool getLastInsertId=false)
virtual void addObject (zmm::Ref< CdsObject > object, int *changedContainer)
virtual void updateObject (zmm::Ref< CdsObject > object, int *changedContainer)
virtual zmm::Ref< CdsObjectloadObject (int objectID)
virtual int getChildCount (int contId, bool containers, bool items, bool hideFsRoot)
virtual zmm::Ref< DBRHash< int > > getObjects (int parentID, bool withoutContainer)
 Get all objects under the given parentID.
virtual zmm::Ref
< ChangedContainers
removeObject (int objectID, bool all)
 Removes the object identified by the objectID from the database. all references will be automatically removed. If the object is a container, all children will be also removed automatically. If the object is a reference to another object, the "all" flag determines, if the main object will be removed too.
virtual zmm::Ref
< ChangedContainers
removeObjects (zmm::Ref< DBRHash< int > > list, bool all=false)
 Remove all objects found in list.
virtual zmm::Ref< CdsObjectloadObjectByServiceID (zmm::String serviceID)
 Loads an object given by the online service ID.
virtual zmm::Ref< zmm::IntArraygetServiceObjectIDs (char servicePrefix)
 Return an array of object ID's for a particular service.
virtual int getTotalFiles ()
virtual zmm::Ref< zmm::Array
< CdsObject > > 
browse (zmm::Ref< BrowseParam > param)
virtual zmm::Ref< zmm::Array
< zmm::StringBase > > 
getMimeTypes ()
virtual zmm::Ref< CdsObjectfindObjectByPath (zmm::String fullpath)
 Loads a given (pc directory) object, identified by the given path from the database.
virtual int findObjectIDByPath (zmm::String fullpath)
 checks for a given (pc directory) object, identified by the given path from the database
virtual zmm::String incrementUpdateIDs (int *ids, int size)
 increments the updateIDs for the given objectIDs
virtual zmm::String buildContainerPath (int parentID, zmm::String title)
 Builds the container path. Fetches the path of the parent and adds the title.
virtual void addContainerChain (zmm::String path, zmm::String lastClass, int lastRefID, int *containerID, int *updateID)
 Adds a virtual container chain specified by path.
virtual zmm::String getInternalSetting (zmm::String key)
virtual void storeInternalSetting (zmm::String key, zmm::String value)=0
virtual void updateAutoscanPersistentList (scan_mode_t scanmode, zmm::Ref< AutoscanList > list)
virtual zmm::Ref< AutoscanListgetAutoscanList (scan_mode_t scanmode)
virtual void addAutoscanDirectory (zmm::Ref< AutoscanDirectory > adir)
virtual void updateAutoscanDirectory (zmm::Ref< AutoscanDirectory > adir)
virtual void removeAutoscanDirectoryByObjectID (int objectID)
virtual void removeAutoscanDirectory (int autoscanID)
virtual int getAutoscanDirectoryType (int objectId)
 returns wheather the given id is an autoscan start point and if yes, if it is persistent
virtual int isAutoscanDirectoryRecursive (int objectId)
 returns wheather the given id is an autoscan start point and if yes, if it is recursive
virtual void autoscanUpdateLM (zmm::Ref< AutoscanDirectory > adir)
 updates the last modified info for the given AutoscanDirectory in the database
virtual zmm::Ref
< AutoscanDirectory
getAutoscanDirectory (int objectID)
 returns the AutoscanDirectory for the given objectID or nil if it's not an autoscan start point - scan id will be invalid
virtual int isAutoscanChild (int objectID)
 checks if the given object is a direct or indirect child of a recursive autoscan start point
virtual void checkOverlappingAutoscans (zmm::Ref< AutoscanDirectory > adir)
virtual zmm::Ref< zmm::IntArraygetPathIDs (int objectID)
virtual void shutdown ()
 shutdown the Storage with its possible threads
virtual void shutdownDriver ()=0
virtual int ensurePathExistence (zmm::String path, int *changedContainer)
 Ensures that a container given by it's location on disk is present in the database. If it does not exist it will be created, but it's content will not be added.
virtual zmm::String getFsRootName ()
virtual void clearFlagInDB (int flag)
 clears the given flag in all objects in the DB

Protected Member Functions

 SQLStorage ()
virtual void init ()
virtual void threadCleanup ()=0
virtual bool threadCleanupRequired ()=0
virtual void registerSingleton ()
void retain ()
void release ()
int getRefCount ()

Static Protected Member Functions

static zmm::Ref< StoragegetInstance ()
static void stripAndUnescapeVirtualContainerFromPath (zmm::String path, zmm::String &first, zmm::String &last)
static zmm::Ref< StoragecreateInstance ()
static void * operator new (size_t size)
static void operator delete (void *ptr)

Protected Attributes

char table_quote_begin
char table_quote_end
mt_atomic_t _ref_count

Static Protected Attributes

static zmm::Ref< Mutexmutex
static zmm::Ref< Storageinstance
static bool singletonActive

Private Member Functions

zmm::String getRealLocation (int parentID, zmm::String location)
zmm::Ref< CdsObjectcreateObjectFromRow (zmm::Ref< SQLRow > row)
zmm::Ref< CdsObject_findObjectByPath (zmm::String fullpath)
int _ensurePathExistence (zmm::String path, int *changedContainer)
zmm::Ref< zmm::Array
< AddUpdateTable > > 
_addUpdateObject (zmm::Ref< CdsObject > obj, bool isUpdate, int *changedContainer)
void _removeObjects (zmm::Ref< zmm::StringBuffer > objectIDs, int offset)
zmm::Ref< ChangedContainersStr_recursiveRemove (zmm::Ref< zmm::StringBuffer > items, zmm::Ref< zmm::StringBuffer > containers, bool all)
virtual zmm::Ref
< ChangedContainers
_purgeEmptyContainers (zmm::Ref< ChangedContainersStr > changedContainersStr)
int _getAutoscanObjectID (int autoscanID)
void _autoscanChangePersistentFlag (int objectID, bool persistent)
zmm::Ref< AutoscanDirectory_fillAutoscanDirectory (zmm::Ref< SQLRow > row)
int _getAutoscanDirectoryInfo (int objectID, zmm::String field)
zmm::Ref< zmm::IntArray_checkOverlappingAutoscans (zmm::Ref< AutoscanDirectory > adir)
zmm::String addLocationPrefix (char prefix, zmm::String path)
zmm::String stripLocationPrefix (char *prefix, zmm::String path)
zmm::String stripLocationPrefix (zmm::String path)
zmm::Ref< CdsObjectcheckRefID (zmm::Ref< CdsObject > obj)
int createContainer (int parentID, zmm::String name, zmm::String path, bool isVirtual, zmm::String upnpClass, int refID)
zmm::String mapBool (bool val)
bool remapBool (zmm::String field)
void setFsRootName (zmm::String rootName=nil)
int getNextID ()
void loadLastID ()
bool cacheOn ()
void addObjectToCache (zmm::Ref< CdsObject > object, bool dontLock=false)
bool doInsertBuffering ()
void addToInsertBuffer (zmm::Ref< zmm::StringBuffer > query)
void flushInsertBuffer (bool dontLock=false)
virtual void _addToInsertBuffer (zmm::Ref< zmm::StringBuffer > query)=0
virtual void _flushInsertBuffer ()=0

Private Attributes

zmm::String sql_query
zmm::String fsRootName
int lastID
zmm::Ref< MutexnextIDMutex
zmm::Ref< StorageCachecache
bool insertBufferOn
bool insertBufferEmpty
int insertBufferStatementCount
int insertBufferByteCount
zmm::Ref< MutexinsertBufferMutex

Detailed Description

Definition at line 73 of file sql_storage.h.


Constructor & Destructor Documentation

SQLStorage::SQLStorage (  )  [protected]

Definition at line 129 of file sql_storage.cc.

References INVALID_OBJECT_ID, lastID, table_quote_begin, and table_quote_end.


Member Function Documentation

virtual void SQLStorage::_addToInsertBuffer ( zmm::Ref< zmm::StringBuffer query  )  [private, pure virtual]

Referenced by addToInsertBuffer().

Ref< Array< SQLStorage::AddUpdateTable > > SQLStorage::_addUpdateObject ( zmm::Ref< CdsObject obj,
bool  isUpdate,
int *  changedContainer 
) [private]
void SQLStorage::_autoscanChangePersistentFlag ( int  objectID,
bool  persistent 
) [private]
Ref< IntArray > SQLStorage::_checkOverlappingAutoscans ( zmm::Ref< AutoscanDirectory adir  )  [private]
int SQLStorage::_ensurePathExistence ( zmm::String  path,
int *  changedContainer 
) [private]
Ref< AutoscanDirectory > SQLStorage::_fillAutoscanDirectory ( zmm::Ref< SQLRow row  )  [private]
Ref< CdsObject > SQLStorage::_findObjectByPath ( zmm::String  fullpath  )  [private]
virtual void SQLStorage::_flushInsertBuffer (  )  [private, pure virtual]

Referenced by flushInsertBuffer().

int SQLStorage::_getAutoscanDirectoryInfo ( int  objectID,
zmm::String  field 
) [private]
int SQLStorage::_getAutoscanObjectID ( int  autoscanID  )  [private]
Ref< Storage::ChangedContainers > SQLStorage::_purgeEmptyContainers ( zmm::Ref< ChangedContainersStr changedContainersStr  )  [private, virtual]
Ref< SQLStorage::ChangedContainersStr > SQLStorage::_recursiveRemove ( zmm::Ref< zmm::StringBuffer items,
zmm::Ref< zmm::StringBuffer containers,
bool  all 
) [private]
void SQLStorage::_removeObjects ( zmm::Ref< zmm::StringBuffer objectIDs,
int  offset 
) [private]
void SQLStorage::addAutoscanDirectory ( zmm::Ref< AutoscanDirectory adir  )  [virtual]
void SQLStorage::addContainerChain ( zmm::String  path,
zmm::String  lastClass,
int  lastRefID,
int *  containerID,
int *  updateID 
) [virtual]

Adds a virtual container chain specified by path.

Parameters:
path container path separated by '/'. Slashes in container titles must be escaped.
lastClass upnp:class of the last container in the chain, it is only set when the container is created for the first time.
lastRefID reference id of the last container in the chain, INVALID_OBJECT_ID indicates that the id will not be set.
containerID will be filled in by the function
updateID will be filled in by the function only if it is set to INVALID_OBJECT_ID and it is necessary to update a container. Otherwise it will be left unchanged.

The function gets a path (i.e. "/Audio/All Music/") and will create the container path if needed. The container ID will be filled in with the object ID of the container that is last in the path. The updateID will hold the objectID of the container that was changed, in case new containers were created during the operation.

Implements Storage.

Definition at line 1073 of file sql_storage.cc.

References addLocationPrefix(), CDS_ID_ROOT, CDS_OBJECT_TABLE, createContainer(), INVALID_OBJECT_ID, LOC_VIRT_PREFIX, nil, NULL, quote(), zmm::String::reduce(), select(), stringHash(), Storage::stripAndUnescapeVirtualContainerFromPath(), TQ, and VIRTUAL_CONTAINER_SEPARATOR.

String SQLStorage::addLocationPrefix ( char  prefix,
zmm::String  path 
) [private]
void SQLStorage::addObject ( zmm::Ref< CdsObject object,
int *  changedContainer 
) [virtual]
void SQLStorage::addObjectToCache ( zmm::Ref< CdsObject object,
bool  dontLock = false 
) [private]
void SQLStorage::addToInsertBuffer ( zmm::Ref< zmm::StringBuffer query  )  [private]
void SQLStorage::autoscanUpdateLM ( zmm::Ref< AutoscanDirectory adir  )  [virtual]

updates the last modified info for the given AutoscanDirectory in the database

Parameters:
adir the AutoscanDirectory to be updated

Implements Storage.

Definition at line 2125 of file sql_storage.cc.

References AUTOSCAN_TABLE, exec(), log_debug, quote(), and TQ.

Ref< Array< CdsObject > > SQLStorage::browse ( zmm::Ref< BrowseParam param  )  [virtual]
String SQLStorage::buildContainerPath ( int  parentID,
zmm::String  title 
) [virtual]

Builds the container path. Fetches the path of the parent and adds the title.

Parameters:
parentID the parent id of the parent container
title the title of the container to add to the path. It will be escaped.

Implements Storage.

Definition at line 1052 of file sql_storage.cc.

References _, _Exception, CDS_ID_ROOT, CDS_OBJECT_TABLE, LOC_VIRT_PREFIX, nil, select(), stripLocationPrefix(), TQ, and VIRTUAL_CONTAINER_SEPARATOR.

bool SQLStorage::cacheOn (  )  [inline, private]
void SQLStorage::checkOverlappingAutoscans ( zmm::Ref< AutoscanDirectory adir  )  [virtual]

Implements Storage.

Definition at line 2158 of file sql_storage.cc.

References _checkOverlappingAutoscans().

Ref< CdsObject > SQLStorage::checkRefID ( zmm::Ref< CdsObject obj  )  [private]

Definition at line 203 of file sql_storage.cc.

References _, _Exception, findObjectByPath(), loadObject(), nil, and string_ok().

Referenced by _addUpdateObject().

void SQLStorage::clearFlagInDB ( int  flag  )  [virtual]

clears the given flag in all objects in the DB

Implements Storage.

Definition at line 2376 of file sql_storage.cc.

References CDS_OBJECT_TABLE, exec(), and TQ.

int SQLStorage::createContainer ( int  parentID,
zmm::String  name,
zmm::String  path,
bool  isVirtual,
zmm::String  upnpClass,
int  refID 
) [private]
Ref< Storage > Storage::createInstance (  )  [static, protected, inherited]

Definition at line 72 of file storage.cc.

References _, _Exception, CFG_SERVER_STORAGE_DRIVER, and Storage::getInstance().

Referenced by Storage::getInstance().

Ref< CdsObject > SQLStorage::createObjectFromRow ( zmm::Ref< SQLRow row  )  [private]
void SQLStorage::dbReady (  ) 

Definition at line 185 of file sql_storage.cc.

References loadLastID(), and nextIDMutex.

bool SQLStorage::doInsertBuffering (  )  [inline, private]

Definition at line 241 of file sql_storage.h.

References insertBufferOn.

Referenced by addObject(), addToInsertBuffer(), and flushInsertBuffer().

int SQLStorage::ensurePathExistence ( zmm::String  path,
int *  changedContainer 
) [virtual]

Ensures that a container given by it's location on disk is present in the database. If it does not exist it will be created, but it's content will not be added.

Parameters:
*changedContainer returns the ID for the UpdateManager
Returns:
objectID of the container given by path

Implements Storage.

Definition at line 963 of file sql_storage.cc.

References _ensurePathExistence(), CDS_ID_FS_ROOT, zmm::String::charAt(), DIR_SEPARATOR, INVALID_OBJECT_ID, zmm::String::length(), zmm::String::reduce(), and zmm::String::substring().

Referenced by _addUpdateObject(), and _ensurePathExistence().

int SQLStorage::exec ( zmm::Ref< zmm::StringBuffer buf,
bool  getLastInsertId = false 
) [inline]

Definition at line 92 of file sql_storage.h.

References exec().

Referenced by exec().

virtual int SQLStorage::exec ( const char *  query,
int  length,
bool  getLastInsertId = false 
) [pure virtual]
Ref< CdsObject > SQLStorage::findObjectByPath ( zmm::String  path  )  [virtual]

Loads a given (pc directory) object, identified by the given path from the database.

Parameters:
path the path of the object; object is interpreted as directory if the path ends with DIR_SEPERATOR, as file otherwise multiple DIR_SEPERATOR are irgnored
Returns:
the CdsObject

Implements Storage.

Definition at line 950 of file sql_storage.cc.

References _findObjectByPath().

Referenced by _ensurePathExistence(), and checkRefID().

int SQLStorage::findObjectIDByPath ( zmm::String  fullpath  )  [virtual]

checks for a given (pc directory) object, identified by the given path from the database

Parameters:
path the path of the object; object is interpreted as directory if the path ends with DIR_SEPERATOR, as file otherwise multiple DIR_SEPERATOR are irgnored
Returns:
the obejectID

Implements Storage.

Definition at line 955 of file sql_storage.cc.

References _findObjectByPath(), INVALID_OBJECT_ID, and nil.

Referenced by addAutoscanDirectory(), and updateAutoscanPersistentList().

void SQLStorage::flushInsertBuffer ( bool  dontLock = false  )  [private]
Ref< AutoscanDirectory > SQLStorage::getAutoscanDirectory ( int  objectID  )  [virtual]

returns the AutoscanDirectory for the given objectID or nil if it's not an autoscan start point - scan id will be invalid

Parameters:
objectID the object id to get the AutoscanDirectory for
Returns:
nil if the given id is no autoscan start point, or the matching AutoscanDirectory

Implements Storage.

Definition at line 1902 of file sql_storage.cc.

References _, _fillAutoscanDirectory(), _StorageException, AUTOSCAN_TABLE, CDS_OBJECT_TABLE, FLD, nil, quote(), select(), TQ, and TQD.

int SQLStorage::getAutoscanDirectoryType ( int  objectId  )  [virtual]

returns wheather the given id is an autoscan start point and if yes, if it is persistent

Parameters:
objectId the object id to check
Returns:
0 if the given id is no autoscan start point, 1 if it is a non-persistent one, 2 if it is a persistent one

Implements Storage.

Definition at line 2070 of file sql_storage.cc.

References _, and _getAutoscanDirectoryInfo().

Ref< AutoscanList > SQLStorage::getAutoscanList ( scan_mode_t  scanmode  )  [virtual]
int SQLStorage::getChildCount ( int  contId,
bool  containers,
bool  items,
bool  hideFsRoot 
) [virtual]
String SQLStorage::getFsRootName (  )  [virtual]

Implements Storage.

Definition at line 2280 of file sql_storage.cc.

References fsRootName, setFsRootName(), and string_ok().

Ref< Storage > Storage::getInstance (  )  [static, inherited]
String SQLStorage::getInternalSetting ( zmm::String  key  )  [virtual]

Implements Storage.

Definition at line 1794 of file sql_storage.cc.

References INTERNAL_SETTINGS_TABLE, nil, quote(), select(), and TQ.

Ref< Array< StringBase > > SQLStorage::getMimeTypes (  )  [virtual]

Implements Storage.

Definition at line 869 of file sql_storage.cc.

References _, _Exception, CDS_OBJECT_TABLE, flushInsertBuffer(), nil, select(), and TQ.

int SQLStorage::getNextID (  )  [private]

Definition at line 2301 of file sql_storage.cc.

References _, _Exception, AUTOLOCK, CDS_ID_FS_ROOT, lastID, and nextIDMutex.

Referenced by addObject(), and createContainer().

Ref< DBRHash< int > > SQLStorage::getObjects ( int  parentID,
bool  withoutContainer 
) [virtual]

Get all objects under the given parentID.

Parameters:
parentID parent container
withoutContainer if false: all children are returned; if true: only items are returned
Returns:
DBHash containing the objectID's - nil if there are none!

Implements Storage.

Definition at line 1343 of file sql_storage.cc.

References _, _Exception, CDS_OBJECT_TABLE, flushInsertBuffer(), INVALID_OBJECT_ID, INVALID_OBJECT_ID_2, nil, OBJECT_TYPE_CONTAINER, select(), and TQ.

Ref< IntArray > SQLStorage::getPathIDs ( int  objectID  )  [virtual]
zmm::String SQLStorage::getRealLocation ( int  parentID,
zmm::String  location 
) [private]
int Object::getRefCount (  )  [inherited]

Definition at line 78 of file object.cc.

References zmm::Object::_ref_count, and atomic_get().

Ref< IntArray > SQLStorage::getServiceObjectIDs ( char  servicePrefix  )  [virtual]

Return an array of object ID's for a particular service.

In the database, the service is identified by a service id prefix.

Implements Storage.

Definition at line 630 of file sql_storage.cc.

References _, _Exception, CDS_OBJECT_TABLE, flushInsertBuffer(), nil, quote(), select(), and TQ.

int SQLStorage::getTotalFiles (  )  [virtual]

Implements Storage.

Definition at line 1257 of file sql_storage.cc.

References CDS_OBJECT_TABLE, flushInsertBuffer(), nil, OBJECT_TYPE_CONTAINER, quote(), select(), and TQ.

String SQLStorage::incrementUpdateIDs ( int *  ids,
int  size 
) [virtual]

increments the updateIDs for the given objectIDs

Parameters:
ids pointer to the array of ids
size number of entries in the given array
Returns:
a String for UPnP: a CSV list; for every existing object: "id,update_id"

Implements Storage.

Definition at line 1274 of file sql_storage.cc.

References _, _Exception, CDS_OBJECT_TABLE, exec(), nil, select(), and TQ.

void SQLStorage::init (  )  [protected, virtual]
int SQLStorage::isAutoscanChild ( int  objectID  )  [virtual]

checks if the given object is a direct or indirect child of a recursive autoscan start point

Parameters:
objectID the object id of the object to check
Returns:
the objectID of the nearest matching autoscan start point or INVALID_OBJECT_ID if it is not a child.

Implements Storage.

Definition at line 2144 of file sql_storage.cc.

References getPathIDs(), INVALID_OBJECT_ID, isAutoscanDirectoryRecursive(), and nil.

int SQLStorage::isAutoscanDirectoryRecursive ( int  objectId  )  [virtual]

returns wheather the given id is an autoscan start point and if yes, if it is recursive

Parameters:
objectId the object id to check
Returns:
0 if the given id is no autoscan start point, 1 if it is a non-recursive one, 2 if it is a recursive on

Implements Storage.

Definition at line 2075 of file sql_storage.cc.

References _, and _getAutoscanDirectoryInfo().

Referenced by isAutoscanChild().

void SQLStorage::loadLastID (  )  [private]

Definition at line 2309 of file sql_storage.cc.

References _, _Exception, CDS_ID_FS_ROOT, CDS_OBJECT_TABLE, lastID, nil, select(), and TQ.

Referenced by dbReady().

Ref< CdsObject > SQLStorage::loadObject ( int  objectID  )  [virtual]
Ref< CdsObject > SQLStorage::loadObjectByServiceID ( zmm::String  serviceID  )  [virtual]

Loads an object given by the online service ID.

Implements Storage.

Definition at line 614 of file sql_storage.cc.

References createObjectFromRow(), flushInsertBuffer(), nil, quote(), select(), SQL_QUERY, and TQD.

zmm::String SQLStorage::mapBool ( bool  val  )  [inline, private]
void Object::operator delete ( void *  ptr  )  [static, inherited]

Definition at line 87 of file object.cc.

References FREE.

void * Object::operator new ( size_t  size  )  [static, inherited]

Definition at line 83 of file object.cc.

References MALLOC.

virtual zmm::String SQLStorage::quote ( char  val  )  [pure virtual]
virtual zmm::String SQLStorage::quote ( bool  val  )  [pure virtual]
virtual zmm::String SQLStorage::quote ( unsigned long  val  )  [pure virtual]
virtual zmm::String SQLStorage::quote ( long  val  )  [pure virtual]
virtual zmm::String SQLStorage::quote ( unsigned int  val  )  [pure virtual]
virtual zmm::String SQLStorage::quote ( int  val  )  [pure virtual]
virtual zmm::String SQLStorage::quote ( zmm::String  str  )  [pure virtual]
virtual void Singleton< Storage >::registerSingleton (  )  [inline, protected, virtual, inherited]

Definition at line 94 of file singleton.h.

void Object::release (  )  [inherited]
bool SQLStorage::remapBool ( zmm::String  field  )  [inline, private]
void SQLStorage::removeAutoscanDirectory ( int  autoscanID  )  [virtual]
void SQLStorage::removeAutoscanDirectoryByObjectID ( int  objectID  )  [virtual]

Implements Storage.

Definition at line 2045 of file sql_storage.cc.

References _autoscanChangePersistentFlag(), AUTOSCAN_TABLE, exec(), INVALID_OBJECT_ID, quote(), and TQ.

Ref< Storage::ChangedContainers > SQLStorage::removeObject ( int  objectID,
bool  all 
) [virtual]

Removes the object identified by the objectID from the database. all references will be automatically removed. If the object is a container, all children will be also removed automatically. If the object is a reference to another object, the "all" flag determines, if the main object will be removed too.

Parameters:
objectID the object id of the object to remove
all if true and the object to be removed is a reference
objectType pointer to an int; will be filled with the objectType of the removed object, if not NULL
Returns:
changed container ids

Implements Storage.

Definition at line 1480 of file sql_storage.cc.

References _, _Exception, _purgeEmptyContainers(), _recursiveRemove(), CDS_OBJECT_TABLE, flushInsertBuffer(), IS_CDS_CONTAINER, IS_FORBIDDEN_CDS_ID, nil, quote(), select(), string_ok(), zmm::String::toInt(), and TQ.

Ref< Storage::ChangedContainers > SQLStorage::removeObjects ( zmm::Ref< DBRHash< int > >  list,
bool  all = false 
) [virtual]

Remove all objects found in list.

Parameters:
list a DBHash containing objectIDs that have to be removed
all if true and the object to be removed is a reference
Returns:
changed container ids

Implements Storage.

Definition at line 1373 of file sql_storage.cc.

References _, _Exception, _purgeEmptyContainers(), _recursiveRemove(), CDS_OBJECT_TABLE, hash_data_array_t< KT >::data, flushInsertBuffer(), IS_CDS_CONTAINER, IS_FORBIDDEN_CDS_ID, nil, select(), hash_data_array_t< KT >::size, and TQ.

void Object::retain (  )  [inherited]
zmm::Ref<SQLResult> SQLStorage::select ( zmm::Ref< zmm::StringBuffer buf  )  [inline]

Definition at line 90 of file sql_storage.h.

References select().

Referenced by select().

virtual zmm::Ref<SQLResult> SQLStorage::select ( const char *  query,
int  length 
) [pure virtual]
void SQLStorage::setFsRootName ( zmm::String  rootName = nil  )  [private]

Definition at line 2288 of file sql_storage.cc.

References CDS_ID_FS_ROOT, fsRootName, loadObject(), and string_ok().

Referenced by getFsRootName(), and updateObject().

void SQLStorage::shutdown (  )  [virtual]

shutdown the Storage with its possible threads

Implements Storage.

Definition at line 191 of file sql_storage.cc.

References flushInsertBuffer(), and shutdownDriver().

virtual void SQLStorage::shutdownDriver (  )  [pure virtual]

Referenced by shutdown().

virtual void SQLStorage::storeInternalSetting ( zmm::String  key,
zmm::String  value 
) [pure virtual]

Implements Storage.

void Storage::stripAndUnescapeVirtualContainerFromPath ( zmm::String  path,
zmm::String first,
zmm::String last 
) [static, protected, inherited]
String SQLStorage::stripLocationPrefix ( zmm::String  path  )  [private]

Definition at line 1123 of file sql_storage.cc.

References nil, and zmm::String::substring().

String SQLStorage::stripLocationPrefix ( char *  prefix,
zmm::String  path 
) [private]
virtual void Storage::threadCleanup (  )  [pure virtual, inherited]
virtual bool Storage::threadCleanupRequired (  )  [pure virtual, inherited]
void SQLStorage::updateAutoscanDirectory ( zmm::Ref< AutoscanDirectory adir  )  [virtual]
void SQLStorage::updateAutoscanPersistentList ( scan_mode_t  scanmode,
zmm::Ref< AutoscanList list 
) [virtual]
void SQLStorage::updateObject ( zmm::Ref< CdsObject object,
int *  changedContainer 
) [virtual]

Field Documentation

mt_atomic_t zmm::Object::_ref_count [protected, inherited]

Definition at line 229 of file sql_storage.h.

Referenced by getFsRootName(), and setFsRootName().

Definition at line 252 of file sql_storage.h.

Referenced by addToInsertBuffer(), flushInsertBuffer(), and init().

Definition at line 250 of file sql_storage.h.

Referenced by addToInsertBuffer(), flushInsertBuffer(), and init().

Definition at line 253 of file sql_storage.h.

Referenced by init().

Definition at line 249 of file sql_storage.h.

Referenced by doInsertBuffering(), and init().

Definition at line 251 of file sql_storage.h.

Referenced by addToInsertBuffer(), flushInsertBuffer(), and init().

zmm::Ref<Storage > Singleton< Storage >::instance [static, protected, inherited]

Definition at line 91 of file singleton.h.

Referenced by Storage::getInstance().

int SQLStorage::lastID [private]

Definition at line 231 of file sql_storage.h.

Referenced by getNextID(), loadLastID(), and SQLStorage().

zmm::Ref<Mutex> Singleton< Storage >::mutex [static, protected, inherited]

Reimplemented from zmm::Object.

Definition at line 90 of file singleton.h.

Referenced by addToInsertBuffer(), flushInsertBuffer(), and Storage::getInstance().

Definition at line 235 of file sql_storage.h.

Referenced by dbReady(), and getNextID().

bool Singleton< Storage >::singletonActive [static, protected, inherited]

Definition at line 92 of file singleton.h.

Definition at line 174 of file sql_storage.h.

Referenced by init().

Definition at line 157 of file sql_storage.h.

Referenced by init(), and SQLStorage().

char SQLStorage::table_quote_end [protected]

Definition at line 158 of file sql_storage.h.

Referenced by init(), and SQLStorage().


The documentation for this class was generated from the following files:

Generated on Fri Mar 26 20:16:57 2010 for MediaTomb by  doxygen 1.6.1