[Bf-blender-cvs] [c5b55a84f58] temp-copy-on-write: cleanup

Jacques Lucke noreply at git.blender.org
Tue Jan 4 13:38:16 CET 2022


Commit: c5b55a84f58aebc302de66fff13816d4beda38ee
Author: Jacques Lucke
Date:   Mon Jan 3 16:57:15 2022 +0100
Branches: temp-copy-on-write
https://developer.blender.org/rBc5b55a84f58aebc302de66fff13816d4beda38ee

cleanup

===================================================================

M	source/blender/blenkernel/BKE_geometry_set.hh
D	source/blender/blenlib/BLI_user_counter.hh
M	source/blender/blenlib/CMakeLists.txt

===================================================================

diff --git a/source/blender/blenkernel/BKE_geometry_set.hh b/source/blender/blenkernel/BKE_geometry_set.hh
index b3e757a83ba..d5a5044d7ad 100644
--- a/source/blender/blenkernel/BKE_geometry_set.hh
+++ b/source/blender/blenkernel/BKE_geometry_set.hh
@@ -30,7 +30,6 @@
 #include "BLI_hash.hh"
 #include "BLI_map.hh"
 #include "BLI_set.hh"
-#include "BLI_user_counter.hh"
 #include "BLI_vector_set.hh"
 
 #include "BKE_anonymous_attribute.hh"
diff --git a/source/blender/blenlib/BLI_user_counter.hh b/source/blender/blenlib/BLI_user_counter.hh
deleted file mode 100644
index 8cebadeac4c..00000000000
--- a/source/blender/blenlib/BLI_user_counter.hh
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-/** \file
- * \ingroup bli
- */
-
-#include <atomic>
-
-namespace blender {
-
-/**
- * A simple automatic reference counter. It is similar to std::shared_ptr, but expects that the
- * reference count is inside the object.
- */
-template<typename T> class UserCounter {
- private:
-  T *data_ = nullptr;
-
- public:
-  UserCounter() = default;
-
-  UserCounter(T *data) : data_(data)
-  {
-  }
-
-  UserCounter(const UserCounter &other) : data_(other.data_)
-  {
-    this->user_add(data_);
-  }
-
-  UserCounter(UserCounter &&other) : data_(other.data_)
-  {
-    other.data_ = nullptr;
-  }
-
-  ~UserCounter()
-  {
-    this->user_remove(data_);
-  }
-
-  UserCounter &operator=(const UserCounter &other)
-  {
-    if (this == &other) {
-      return *this;
-    }
-
-    this->user_remove(data_);
-    data_ = other.data_;
-    this->user_add(data_);
-    return *this;
-  }
-
-  UserCounter &operator=(UserCounter &&other)
-  {
-    if (this == &other) {
-      return *this;
-    }
-
-    this->user_remove(data_);
-    data_ = other.data_;
-    other.data_ = nullptr;
-    return *this;
-  }
-
-  T *operator->()
-  {
-    BLI_assert(data_ != nullptr);
-    return data_;
-  }
-
-  const T *operator->() const
-  {
-    BLI_assert(data_ != nullptr);
-    return data_;
-  }
-
-  T &operator*()
-  {
-    BLI_assert(data_ != nullptr);
-    return *data_;
-  }
-
-  const T &operator*() const
-  {
-    BLI_assert(data_ != nullptr);
-    return *data_;
-  }
-
-  operator bool() const
-  {
-    return data_ != nullptr;
-  }
-
-  T *get()
-  {
-    return data_;
-  }
-
-  const T *get() const
-  {
-    return data_;
-  }
-
-  T *release()
-  {
-    T *data = data_;
-    data_ = nullptr;
-    return data;
-  }
-
-  void reset()
-  {
-    this->user_remove(data_);
-    data_ = nullptr;
-  }
-
-  bool has_value() const
-  {
-    return data_ != nullptr;
-  }
-
-  uint64_t hash() const
-  {
-    return get_default_hash(data_);
-  }
-
-  friend bool operator==(const UserCounter &a, const UserCounter &b)
-  {
-    return a.data_ == b.data_;
-  }
-
-  friend std::ostream &operator<<(std::ostream &stream, const UserCounter &value)
-  {
-    stream << value.data_;
-    return stream;
-  }
-
- private:
-  static void user_add(T *data)
-  {
-    if (data != nullptr) {
-      data->user_add();
-    }
-  }
-
-  static void user_remove(T *data)
-  {
-    if (data != nullptr) {
-      data->user_remove();
-    }
-  }
-};
-
-}  // namespace blender
diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt
index aeb85ab3eac..5c1b3122dea 100644
--- a/source/blender/blenlib/CMakeLists.txt
+++ b/source/blender/blenlib/CMakeLists.txt
@@ -312,7 +312,6 @@ set(SRC
   BLI_timecode.h
   BLI_timeit.hh
   BLI_timer.h
-  BLI_user_counter.hh
   BLI_utildefines.h
   BLI_utildefines_iter.h
   BLI_utildefines_stack.h



More information about the Bf-blender-cvs mailing list