From 1d6d1e8c73193f57a9c98387ea42eb91eb4d21d1 Mon Sep 17 00:00:00 2001 From: Georg Holzmann Date: Fri, 21 Oct 2005 11:56:32 +0000 Subject: only moving to a new directory svn path=/trunk/externals/grh/; revision=3740 --- PDContainer/include/ContainerBase.h | 136 ++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 PDContainer/include/ContainerBase.h (limited to 'PDContainer/include/ContainerBase.h') diff --git a/PDContainer/include/ContainerBase.h b/PDContainer/include/ContainerBase.h new file mode 100755 index 0000000..c32a22a --- /dev/null +++ b/PDContainer/include/ContainerBase.h @@ -0,0 +1,136 @@ +// *********************(c)*2004*********************> +// -holzilib--holzilib--holzilib--holzilib--holzilib-> +// ++++PD-External++by+Georg+Holzmann++grh@gmx.at++++> +// +// PDContainer: +// this is a port of the containers from the C++ STL +// (Standard Template Library) +// for usage see the documentation and PD help files +// for license see readme.txt +// +// ContainerBase.h + + +#ifndef _container_base_h___ +#define _container_base_h___ + + +#include "include/GlobalStuff.h" +#include + +using std::map; + + +//--------------------------------------------------- +/* this is the base class of all the containers + */ +template +class ContainerBase +{ + protected: + + /* this is the static container with all the datas + * the string is the namespace of the Container + */ + static map data_; + + /* holds the number of the current namespace + * (the string of the namespace is stored in the map above) + */ + string h_namespace_; + + /* this string is the name of the datatype + * (e.g. h_set, h_map, ...) + */ + string dataname_; + + private: + + /* Copy Construction is not allowed + */ + ContainerBase(const ContainerBase &src) + { } + + /* assignement operator is not allowed + */ + const ContainerBase& operator = + (const ContainerBase&) + { } + + public: + + /* Standard Constructor + * no namespace + */ + ContainerBase() + { } + + /* Destructor + */ + virtual ~ContainerBase() + { } + + /* sets the namespace variable + */ + void setNamespace(string h_namespace) + { + h_namespace_ = h_namespace; + //ContainerType container; + //data_.insert(std::pair(h_namespace_,container)); + } + + /* get the namespace string + */ + string getNamespace() const + { return h_namespace_; } + + /* prints out the help text + */ + virtual void help(); + + /* clears all the data of the current namespaces + * in all objects from the same container + */ + virtual void clearNamespace() + { data_.erase(h_namespace_); } + + /* clears all the data of the current container + * ( in all namespaces !!!!! ) + * so be carefull !!! + */ + virtual void clearAll() + { data_.clear(); } + + /* get the size of the container + */ + virtual int getSize() const + { return data_[h_namespace_].size(); } +}; + + +//--------------------------------------------------- +/* defines the static members + */ +template +map ContainerBase::data_; + +//--------------------------------------------------- +/* prints out the help text + */ +template +void ContainerBase::help() +{ + post("\nPD-Container, Version: "PDC_VERSION""); + post("object: %s",dataname_.c_str()); + post("------------------------------------------"); + post("this is an implementation of the container"); + post("objects from the Standard Template"); + post("Library (STL) of C++"); + post("for documentation see the help patches"); + post("(by Georg Holzmann , 2004-2005)"); + post("------------------------------------------\n"); +} + + + +#endif //_container_base_h___ -- cgit v1.2.1