Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-19 08:08:31

0001 // Property lists.
0002 
0003 #ifndef _CL_PROPLIST_H
0004 #define _CL_PROPLIST_H
0005 
0006 #include "cln/symbol.h"
0007 #include "cln/malloc.h"
0008 
0009 namespace cln {
0010 
0011 // The only extensible way to extend objects at runtime in an extensible
0012 // and decentralized way (without having to modify the object's class)
0013 // is to add a property table to every object.
0014 // For the moment, only very few properties are planned, so lists should be
0015 // enough. Since properties represent additional information about the object,
0016 // there is no need for removing properties, so singly linked lists will be
0017 // enough.
0018 
0019 // This is the base class for all properties.
0020 struct cl_property {
0021 private:
0022     cl_property* next;
0023 public:
0024     cl_symbol key;
0025     // Constructor.
0026     cl_property (const cl_symbol& k) : next (NULL), key (k) {}
0027     // Destructor.
0028     virtual ~cl_property () {}
0029     // Allocation and deallocation.
0030     void* operator new (size_t size) { return malloc_hook(size); }
0031     void operator delete (void* ptr) { free_hook(ptr); }
0032 private:
0033     virtual void dummy ();
0034 // Friend declarations. They are for the compiler. Just ignore them.
0035     friend class cl_property_list;
0036 };
0037 #define SUBCLASS_cl_property() \
0038     void* operator new (size_t size) { return malloc_hook(size); } \
0039     void operator delete (void* ptr) { free_hook(ptr); }
0040 
0041 struct cl_property_list {
0042 private:
0043     cl_property* list;
0044 public:
0045     cl_property* get_property (const cl_symbol& key);
0046     void add_property (cl_property* new_property);
0047     // Constructor.
0048     cl_property_list () : list (NULL) {}
0049     // Destructor.
0050     ~cl_property_list ();
0051 };
0052 
0053 }  // namespace cln
0054 
0055 #endif /* _CL_PROPLIST_H */