aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/oo/Properties.h
blob: f19e300cfeff546cafd2ae81cec10228e62ab97d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef   oo_Properties_H__
#define   oo_Properties_H__

#include "ObjBase.h"

#include <map>
#include <queue>

#include <cstdlib>

namespace meow{
  class Properties: public ObjBase{
    private:
      struct Property{
        ObjBase*    _pointer;
        ssize_t     _counter;
        //
        Property(ObjBase* __pointer, bool __autoRemove);
        Property(Property const& __property);
        ~Property();
        //
        bool attach();
        bool detach();
      };
      //
      std::map<size_t, Property*>   _properties;
      std::map<std::string, size_t> _index;
      std::queue<size_t>            _freeIndex;
      //
      size_t newIndex(std::string const& __name);
      void   delIndex(size_t __index);
      void   detach(size_t __index);
    public:
      Properties();
      Properties(Properties const& __p);
      ~Properties();
      //
      void        clear();
      Properties& copy (Properties const& __p);
      //
      size_t size () const;
      bool   empty() const;
      //
      bool chg(size_t      __index, ObjBase* __pointer, bool __autoRemove);
      bool add(std::string __name , ObjBase* __pointer, bool __autoRemove);
      bool del(size_t      __index);
      bool del(std::string __name );
      ObjBase*    get(size_t      __index) const;
      ObjBase*    get(std::string __name ) const;
      ssize_t     getIndex(ObjBase* __pointer) const;
      std::string getName (ObjBase* __pointer) const;
      //
      Properties& operator=(Properties const& __p);
      ObjBase* operator()(size_t      __index) const;
      ObjBase* operator()(std::string __name ) const;
  };
}

#include "Properties.hpp"

#endif // oo_Properties_H__