1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 * This file contains the Savable class.
32 * An interface to for SavableManager wrappers.
34 * This interface is meant to wrap a SavableManager.
35 * It provides basic functionality to allow general interaction with SavableManagers.
42 /** Construct a new Savable. */
45 /** Destructor, a noop. */
46 virtual ~Savable(void);
48 /** Delete this savable. */
49 virtual void Delete() = 0;
51 /** Save this savable. */
52 virtual void Save() = 0;
54 /** Delete this savable providing details as to who deleted it and why. */
55 virtual void Delete(value_type accountid
, const std::string
& description
) ;
57 /** Save this savable providing details as to who deleted it and why. */
58 virtual void Save(value_type accountid
, const std::string
& description
) ;
60 /** Discard changes made to this savable. */
61 virtual void Discard() = 0;
63 /** Wether this savable has been saved yet. */
64 virtual bool Exists() = 0;
66 /** Locks the manager if no lock was aquired yet.
68 * <code>getManager()</code> is asserted not to return NULL.
69 * If no lock could be aquired throws SavableLocked.
70 * When called succesfully (that is, without throwing) a lock is aquired.
71 * If a lock is aquired, <code>Unlock</code> should be called before the savable is destroyed.
79 /** Unlocks the savable if we previously aquired a lock. */
82 /** Returns an elaborate string representation of the savable, getManager() is asserted not to return NULL. */
83 virtual std::vector
<std::string
> toStrings();
85 /** Returns a one-line string representation of the savable, getManager() is asserted not to return NULL. */
86 virtual std::string
toString();
89 /** Returns the table this savable belongs to. */
90 virtual TableImplPtr
getTable() const = 0;
92 /** Returns the SavableManager this savable usesotherwise. */
93 virtual SavableManagerPtr
getManager() const = 0;
95 bool m_haslock
; /**< Whether we have a lock on our savable. */
98 /** Hide the copy constructor. */
99 Savable(const Savable
& rhs
);
102 typedef SmartPtr
<Savable
> SavablePtr
; /**< The type of a pointer to a savable. */