From 99b0acf5565ae10f9edc72ce80b545ce6ad2d046 Mon Sep 17 00:00:00 2001 From: Hleb Valoshka <375gnu@gmail.com> Date: Mon, 28 Oct 2019 23:43:08 +0300 Subject: [PATCH] Make Selection variables private again --- src/celengine/category.h | 2 +- src/celengine/selection.h | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/celengine/category.h b/src/celengine/category.h index 4f1bbea1..c22b6dc3 100644 --- a/src/celengine/category.h +++ b/src/celengine/category.h @@ -11,7 +11,7 @@ public: { size_t operator()(const Selection &s) const { - return (size_t)s.obj; + return (size_t)s.catEntry(); } }; diff --git a/src/celengine/selection.h b/src/celengine/selection.h index 13fbd5f7..3d3389f9 100644 --- a/src/celengine/selection.h +++ b/src/celengine/selection.h @@ -23,7 +23,8 @@ class DeepSkyObject; class Selection { public: - enum Type { + enum Type + { Type_Nil, Type_Star, Type_Body, @@ -32,15 +33,14 @@ class Selection Type_Generic }; -public: - Selection() : type(Type_Nil), obj(nullptr) {}; + Selection() = default; Selection(CatEntry *cat) : type(Type_Generic), obj(cat) { checkNull(); }; Selection(Star* star) : type(Type_Star), obj(star) { checkNull(); }; Selection(Body* body) : type(Type_Body), obj(body) { checkNull(); }; Selection(DeepSkyObject* deepsky) : type(Type_DeepSky), obj(deepsky) {checkNull(); }; Selection(Location* location) : type(Type_Location), obj(location) { checkNull(); }; Selection(const Selection& sel) : type(sel.type), obj(sel.obj) {}; - ~Selection() {}; + ~Selection() = default; bool empty() const { return type == Type_Nil; } double radius() const; @@ -78,11 +78,14 @@ public: Type getType() const { return type; } - // private: - Type type; - void* obj; + private: + Type type { Type_Nil }; + void* obj { nullptr }; void checkNull() { if (obj == nullptr) type = Type_Nil; } + + friend bool operator==(const Selection& s0, const Selection& s1); + friend bool operator!=(const Selection& s0, const Selection& s1); };