/* PIP - Platform Independent Primitives Introspection module - interface for containers Ivan Pelipenko peri4ko@yandex.ru This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ #ifndef PIINTROSPECTION_CONTAINERS_H #define PIINTROSPECTION_CONTAINERS_H #include "pibase.h" struct PIP_EXPORT PIIntrospectionContainersType { ~PIIntrospectionContainersType(); void finish(); uint id = 0; const char * name = nullptr; const char * demangled = "?"; bool inited = false; bool has_demangled = false; }; #if defined(PIP_INTROSPECTION) && !defined(PIP_FORCE_NO_PIINTROSPECTION) # include "piintrospection_base.h" class PIIntrospectionContainers; template class PIIntrospectionContainersTypeInfo { public: static const PIIntrospectionContainersType & get() { static PIIntrospectionContainersType ret = create(); return ret; } private: static PIIntrospectionContainersType create() { PIIntrospectionContainersType ret; ret.name = __PIP_TYPENAME__(T); ret.finish(); return ret; } }; # define PIINTROSPECTION_CONTAINERS (PIIntrospectionContainersInterface::instance()) // clang-format off # define PIINTROSPECTION_CONTAINER_NEW(t, isz) PIINTROSPECTION_CONTAINERS->containerNew (PIIntrospectionContainersTypeInfo::get(), isz); # define PIINTROSPECTION_CONTAINER_DELETE(t) PIINTROSPECTION_CONTAINERS->containerDelete(PIIntrospectionContainersTypeInfo::get() ); # define PIINTROSPECTION_CONTAINER_ALLOC(t, cnt) PIINTROSPECTION_CONTAINERS->containerAlloc (PIIntrospectionContainersTypeInfo::get(), cnt); # define PIINTROSPECTION_CONTAINER_FREE(t, cnt) PIINTROSPECTION_CONTAINERS->containerFree (PIIntrospectionContainersTypeInfo::get(), cnt); # define PIINTROSPECTION_CONTAINER_USED(t, cnt) PIINTROSPECTION_CONTAINERS->containerUsed (PIIntrospectionContainersTypeInfo::get(), cnt); # define PIINTROSPECTION_CONTAINER_UNUSED(t, cnt) PIINTROSPECTION_CONTAINERS->containerUnused(PIIntrospectionContainersTypeInfo::get(), cnt); // clang-format on class PIP_EXPORT PIIntrospectionContainersInterface { friend class PIIntrospection; friend class PIIntrospectionServer; public: __PIINTROSPECTION_SINGLETON_H__(Containers) // clang-format off void containerNew (const PIIntrospectionContainersType & ti, uint isz); void containerDelete(const PIIntrospectionContainersType & ti); void containerAlloc (const PIIntrospectionContainersType & ti, ullong cnt); void containerFree (const PIIntrospectionContainersType & ti, ullong cnt); void containerUsed (const PIIntrospectionContainersType & ti, ullong cnt); void containerUnused(const PIIntrospectionContainersType & ti, ullong cnt); // clang-format on PIIntrospectionContainers * p; private: PIIntrospectionContainersInterface(); ~PIIntrospectionContainersInterface(); }; #else # define PIINTROSPECTION_CONTAINER_NEW(t, isz) # define PIINTROSPECTION_CONTAINER_DELETE(t) # define PIINTROSPECTION_CONTAINER_ALLOC(t, cnt) # define PIINTROSPECTION_CONTAINER_FREE(t, cnt) # define PIINTROSPECTION_CONTAINER_USED(t, cnt) # define PIINTROSPECTION_CONTAINER_UNUSED(t, cnt) #endif #endif // PIINTROSPECTION_CONTAINERS_H