User Manual, Developers Guide and API Documentation

ObjManager.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WNS (Wireless Network Simulator)                                           *
00003  * __________________________________________________________________________ *
00004  *                                                                            *
00005  * Copyright (C) 2004-2006                                                    *
00006  * Chair of Communication Networks (ComNets)                                  *
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany                                 *
00008  * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242                   *
00009  * email: wns@comnets.rwth-aachen.de                                          *
00010  * www: http://wns.comnets.rwth-aachen.de                                     *
00011  ******************************************************************************/
00016 #ifndef WNS_OBJMANAGER_HPP
00017 #define WNS_OBJMANAGER_HPP
00018 
00019 #include <algorithm>
00020 #include <list>
00021 
00022 #include <WNS/Exception.hpp>
00023 #include <WNS/SmartPtr.hpp>
00024 
00025 namespace wns {
00029     template <class OBJECT>
00030     class ObjectManager
00031     {
00032     public:
00033         typedef SmartPtr<OBJECT> ObjPtr;
00034         typedef OBJECT Object;
00035 
00036 
00037         template <class>
00038         void
00039         clear()
00040         {
00041             objects.clear();
00042         }
00043 
00044         void append(const OBJECT& obj)
00045         {
00046             objects.push_back( obj );
00047         }
00048 
00050         template<class FUNCTION>
00051         FUNCTION for_each( FUNCTION function)
00052         {
00053             return std::for_each( objects.begin(), objects.end(), function );
00054         }
00055 
00056         size_t size() const
00057         {
00058             return objects.size();
00059         }
00060 
00061     protected:
00062 
00063         std::list< Object > objects;
00064     };
00065 }
00066 #endif
00067 

Generated on Fri May 25 03:31:49 2012 for openWNS by  doxygen 1.5.5