MI - Fimex
CDMNamedEntity.h
Go to the documentation of this file.
1 /*
2  * Fimex
3  *
4  * (C) Copyright 2008, met.no
5  *
6  * Project Info: https://wiki.met.no/fimex/start
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21  * USA.
22  */
23 
24 #ifndef CDMNAMEDENTITY_H_
25 #define CDMNAMEDENTITY_H_
26 
27 #include <string>
28 #include <functional>
29 #include <boost/shared_ptr.hpp>
30 
31 namespace MetNoFimex
32 {
33 
34 
43 {
44 public:
45  virtual ~CDMNamedEntity() = 0;
46  virtual const std::string& getName() const = 0;
47 };
48 
52 struct CDMNameCompare : public std::binary_function<CDMNamedEntity, CDMNamedEntity, int>
53 {
54 public:
55  int operator()(const CDMNamedEntity& e1, const CDMNamedEntity& e2) {return e1.getName().compare(e2.getName());}
56 };
57 
61 class CDMNameEqual : public std::unary_function<CDMNamedEntity, bool>
62 {
63 public:
64  explicit CDMNameEqual(std::string name) : name(name) {}
65  explicit CDMNameEqual(const CDMNamedEntity& entity) : name(entity.getName()) {}
67  bool operator()(const CDMNamedEntity& e) {return name == e.getName();}
68 private:
69  std::string name;
70 };
71 
75 class CDMNameEqualPtr : public std::unary_function<boost::shared_ptr<CDMNamedEntity>, bool>
76 {
77 public:
78  explicit CDMNameEqualPtr(std::string name) : name(name) {}
79  explicit CDMNameEqualPtr(const boost::shared_ptr<const CDMNamedEntity>& entity) : name(entity->getName()) {}
81  bool operator()(const boost::shared_ptr<const CDMNamedEntity>& e) {return name == e->getName();}
82 private:
83  std::string name;
84 };
85 
86 }
87 
88 #endif /*CDMNAMEDENTITY_H_*/
Definition: CDMNamedEntity.h:42
basic_string< char > string
bool operator()(const CDMNamedEntity &e)
Definition: CDMNamedEntity.h:67
bool operator()(const boost::shared_ptr< const CDMNamedEntity > &e)
Definition: CDMNamedEntity.h:81
CDMNameEqual(const CDMNamedEntity &entity)
Definition: CDMNamedEntity.h:65
~CDMNameEqual()
Definition: CDMNamedEntity.h:66
int operator()(const CDMNamedEntity &e1, const CDMNamedEntity &e2)
Definition: CDMNamedEntity.h:55
Definition: C_CDMReader.h:35
CDMNameEqualPtr(std::string name)
Definition: CDMNamedEntity.h:78
virtual const std::string & getName() const =0
CDMNameEqualPtr(const boost::shared_ptr< const CDMNamedEntity > &entity)
Definition: CDMNamedEntity.h:79
~CDMNameEqualPtr()
Definition: CDMNamedEntity.h:80
CDMNameEqual(std::string name)
Definition: CDMNamedEntity.h:64
Definition: CDMNamedEntity.h:75
Definition: CDMNamedEntity.h:61
Definition: CDMNamedEntity.h:52