核动力机器人的代码-资源和资源管理器

/* [email protected] 1.21.2009 */ #ifndef G_RESOURCEMANAGER_HPP #define G_RESOURCEMANAGER_HPP #include <string> #include <vector> #include <boost/utility.hpp> #include "gexception.hpp" #include "gtrinode.hpp" namespace g { namespace manager { //class resource. class Resource { public: Resource(){} virtual ~Resource(){} public: virtual bool load(const std::string filename)= 0; }; class ResourceDescriptor { public: ResourceDescriptor() { } ResourceDescriptor(const std::string& p) : path(p) { } public: std::string path; }; class AbstactorResourceManger : boost::noncopyable { typedef g::gstl::trinode<std::string, std::string, Resource* > Restri; typedef std::vector<g::gstl::trinode<std::string, std::string, Resource* > >Res; typedef std::vector<g::gstl::trinode<std::string, std::string, Resource* > >::iterator ResItr; public: AbstactorResourceManger(){resList.clear();} virtual ~AbstactorResourceManger() = 0; public: inline void clear(){resList.clear();} inline bool empty(){return resList.empty();} inline ResItr find(const std::string name) { return find_if(resList.begin(), resList.end(), Find(name)) ; } //inline void add(Resource*) {resList.push_back();} protected: Res resList; private: class Find { public: Find(std::string _name):name(_name){} bool operator()(const Restri &res) const { if(res.lvalue.compare(name)==0) return true; } private: std::string name; }; }; } } #endif

 

dev c++测试通过

 

以下是find_if的英文说明:

Find element in range

      Returns an iterator to the first element in the range [first,last) for which applying pred to it, is true.

 

关于其复杂度:

      At most, performs as many applications of pred as the number of elements in the range [first,last).

你可能感兴趣的:(String,manager,测试,iterator,Class,Path)