Make Selection variables private again

pull/3/head
Hleb Valoshka 2019-10-28 23:43:08 +03:00
parent f8fcc4c0ae
commit 99b0acf556
2 changed files with 11 additions and 8 deletions

View File

@ -11,7 +11,7 @@ public:
{
size_t operator()(const Selection &s) const
{
return (size_t)s.obj;
return (size_t)s.catEntry();
}
};

View File

@ -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);
};