Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Asset/assetbase.cpp')
-rw-r--r--Source/Asset/assetbase.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/Source/Asset/assetbase.cpp b/Source/Asset/assetbase.cpp
new file mode 100644
index 00000000..3623ab03
--- /dev/null
+++ b/Source/Asset/assetbase.cpp
@@ -0,0 +1,81 @@
+//-----------------------------------------------------------------------------
+// Name: assetbase.cpp
+// Developer: Wolfire Games LLC
+// Description:
+// License: Read below
+//-----------------------------------------------------------------------------
+//
+//
+// Copyright 2022 Wolfire Games LLC
+//
+// 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.
+//
+//-----------------------------------------------------------------------------
+#include "assetbase.h"
+
+#include <Asset/assetmanager.h>
+#include <Logging/logdata.h>
+
+#if defined(__GNUG__) && !defined(NDEBUG)
+#include <cxxabi.h>
+#endif
+
+#include <cstdlib>
+#include <cassert>
+
+Asset::Asset(AssetManager* owner, uint32_t asset_id):
+asset_id(asset_id),
+owner(owner) {
+
+}
+
+Asset::~Asset()
+{
+ /*
+ if( ref_count_ != 0 )
+ {
+ #if defined(__GNUG__) && !defined(NDEBUG)
+ int status;
+ char *realname;
+
+ // typeid
+ const std::type_info &ti = typeid(*this);
+
+ realname = abi::__cxa_demangle(ti.name(), 0, 0, &status);
+ LOGE << "For some reason the ref_count in asset \"" << realname << "\" isn't 0 it's: " << ref_count_ << std::endl;
+ OG_FREE(realname);
+ #else
+
+ LOGE << "For some reason the ref_count in asset \"" << GetName() << "\" isn't 0 it's: " << ref_count_ << std::endl;
+ #endif
+ }
+ */
+}
+
+void Asset::IncrementRefCount()
+{
+ if( owner ) {
+ owner->IncrementAsset(asset_id);
+ } else {
+ LOGE << "This asset was orphaned before it was destroyed, someone was holding a reference too long" << std::endl;
+ }
+}
+
+void Asset::DecrementRefCount()
+{
+ if( owner ) {
+ owner->DecrementAsset(asset_id);
+ } else {
+ LOGE << "This asset was orphaned before it was destroyed, someone was holding a reference too long" << std::endl;
+ }
+}