Add a filter-by-from/to-chunk in ExitManager::List.
[UnsignedByte.git] / src / DB / Savables / Savable.h
blobb2fbd5be32d57bf9ad3c740390c8fbef6951f74b
1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20 #pragma once
22 /**
23 * @file Savable.h
24 * This file contains the Savable class.
26 * @see Savable
27 */
29 #include "Types.h"
31 /**
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.
37 * @see SavableManager
38 */
39 class Savable
41 public:
42 /** Construct a new Savable. */
43 Savable(void);
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.
73 * @see getManager
74 * @see SavableLocked
75 * @see Unlock
76 */
77 void Lock();
79 /** Unlocks the savable if we previously aquired a lock. */
80 void Unlock();
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;
91 protected:
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. */
97 private:
98 /** Hide the copy constructor. */
99 Savable(const Savable& rhs);
102 typedef SmartPtr<Savable> SavablePtr; /**< The type of a pointer to a savable. */