aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/kernel/resource.h
diff options
context:
space:
mode:
authorEugene Sandulenko2010-07-29 19:53:02 +0000
committerEugene Sandulenko2010-10-12 21:38:20 +0000
commita683a420a9e43705c972b5e74d55e319729e1a81 (patch)
treebde6e4abd417bdfaec120aa951da9a19be36b654 /engines/sword25/kernel/resource.h
parent7723d91c957d07205c51be32498d45cd0a78568f (diff)
downloadscummvm-rg350-a683a420a9e43705c972b5e74d55e319729e1a81.tar.gz
scummvm-rg350-a683a420a9e43705c972b5e74d55e319729e1a81.tar.bz2
scummvm-rg350-a683a420a9e43705c972b5e74d55e319729e1a81.zip
SWORD25: Importing original sources
svn-id: r53171
Diffstat (limited to 'engines/sword25/kernel/resource.h')
-rwxr-xr-xengines/sword25/kernel/resource.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/engines/sword25/kernel/resource.h b/engines/sword25/kernel/resource.h
new file mode 100755
index 0000000000..5d6c542b07
--- /dev/null
+++ b/engines/sword25/kernel/resource.h
@@ -0,0 +1,97 @@
+// -----------------------------------------------------------------------------
+// This file is part of Broken Sword 2.5
+// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer
+//
+// Broken Sword 2.5 is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// Broken Sword 2.5 is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Broken Sword 2.5; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+// -----------------------------------------------------------------------------
+
+#ifndef BS_RESOURCE_H
+#define BS_RESOURCE_H
+
+#include "memlog_off.h"
+#include <list>
+#include "memlog_on.h"
+
+#include "common.h"
+
+class BS_Kernel;
+class BS_ResourceManager;
+
+class BS_Resource
+{
+friend BS_ResourceManager;
+
+public:
+ enum RESOURCE_TYPES
+ {
+ TYPE_UNKNOWN,
+ TYPE_BITMAP,
+ TYPE_ANIMATION,
+ TYPE_SOUND,
+ TYPE_FONT
+ };
+
+ BS_Resource(const std::string& UniqueFileName, RESOURCE_TYPES Type);
+
+ /**
+ * @brief `Lockt' die Resource, verhindert, dass sie freigegeben wird.
+ * @remarks Die Resource wird bereits `gelockt' initialisiert, sie muss also nach dem Anfordern nur
+ * gelockt werden, wenn sie mehrfach verwendet wird.
+ **/
+
+ void AddReference() { ++_RefCount; }
+
+ /**
+ * @brief Hebt ein vorhergehendes `lock' auf.
+ * @remarks Die Resource kann ruhig öfter freigegeben als `gelockt' werden, auch wenn das nicht gerade empfehlenswert ist.
+ **/
+
+ void Release();
+
+ /**
+ * @brief Gibt die Anzahl der aktuellen `locks' zurück.
+ * @return Die Zahl der `locks'.
+ **/
+
+ int GetLockCount() const { return _RefCount; }
+
+ /**
+ @brief Gibt den absoluten, eindeutigen Dateinamen der Resource zurück.
+ */
+
+ const std::string & GetFileName() const { return _FileName; }
+
+ /**
+ @brief Gibt den Hash des Dateinames der Resource zurück.
+ */
+ unsigned int GetFileNameHash() const { return _FileNameHash; }
+
+ /**
+ @brief Gibt den Typ der Ressource zurück.
+ */
+ unsigned int GetType() const { return _Type; }
+
+protected:
+ virtual ~BS_Resource() {};
+
+private:
+ std::string _FileName; //!< Der absolute Dateiname
+ unsigned int _FileNameHash; //!< Der Hashwert des Dateinames
+ unsigned int _RefCount; //!< Anzahl an Locks
+ unsigned int _Type; //!< Der Typ der Resource
+ std::list<BS_Resource*>::iterator _Iterator; //!< Der Iterator zeigt auf Position der Resource in der LRU-Liste
+};
+
+#endif