diff --git a/include/boost/utility/obj_id.hpp b/include/boost/utility/obj_id.hpp new file mode 100644 index 0000000..62a1622 --- /dev/null +++ b/include/boost/utility/obj_id.hpp @@ -0,0 +1,43 @@ +#ifndef UTILITY_OBJ_ID_HPP +#define UTILITY_OBJ_ID_HPP +namespace utility + { + struct obj_id + /**@class obj_id + * @brief Provide unique id for objects + */ + { + typedef + unsigned + id_type + ; + virtual //To make subj_described* start with obj_id* + //See stl_container.log@@2003-06-05.0750 + ~obj_id(void) + {} + obj_id(void) + :m_id(the_last_id()++) + {} + obj_id(obj_id const&) + :m_id(the_last_id()++) + {} + void + operator=(obj_id const&) + {} + id_type + id_get(void)const + { return m_id + ;} + static + id_type& + the_last_id(void) + //reference to count if id's created + ; + private: + id_type + m_id + ; + };//end obj_id struct + }//exit utility namespace +#endif + diff --git a/include/boost/utility/object_tracked.hpp b/include/boost/utility/object_tracked.hpp new file mode 100644 index 0000000..5925a82 --- /dev/null +++ b/include/boost/utility/object_tracked.hpp @@ -0,0 +1,89 @@ +//Simple class which keeps track of members +#ifndef UTILITY_OBJECT_TRACKED_HPP_LJE20040112 +#define UTILITY_OBJECT_TRACKED_HPP_LJE20040112 +#include +#include "boost/utility/obj_id.hpp" +#include "boost/io/filters/mout.hpp" +namespace utility +{ +class object_tracked +: public obj_id +{ + public: + struct + set_of_objects_tracked + : public std::set + { + typedef + std::set + super_type + ; + set_of_objects_tracked(void) + {} + void + reset(void) + { + super_type::clear(); + obj_id::the_last_id() = 0; + } + bool + contains(object_tracked const*& a_obj)const + { + return find(a_obj) != end(); + } + + }; + static + set_of_objects_tracked + our_members + ; + static + unsigned + members_size(void) + { + return our_members.size(); + } + + object_tracked(void) + { + our_members.insert(this); + #ifdef UTILITY_OBJECT_TRACKED_TRACE_MODE + mout()<<"object_tracked+:id="< +namespace utility +{ + class +trace_scope + //Purpose: + // Indicate on cout when a scope entered and exited. + { + public: + trace_scope(char const* a_scopeName) + : m_scopeName(a_scopeName) + { init() + ;} + trace_scope(std::string const& a_scopeName) + : m_scopeName(a_scopeName) + { init() + ;} + ~trace_scope(void) + { + ; --mout() + ; std::string l_context("===>Exit:") + ; mout()<Enter:") + ; mout()<