NameOf.h 596 Bytes
Newer Older
Francois Gygi committed
1 2 3 4 5
////////////////////////////////////////////////////////////////////////////////
//
// NameOf.h:
//
////////////////////////////////////////////////////////////////////////////////
6
// $Id: NameOf.h,v 1.2 2007-03-17 01:14:00 fgygi Exp $
Francois Gygi committed
7 8 9 10 11 12 13 14 15 16 17 18

#ifndef NAMEOF_H
#define NAMEOF_H

#include <string>

// predicate class for searching T* containers by name
// T must be a pointer type to something that has a name() member
template <class T>
class NameOf
{
  public:
19
  std::string name;
Francois Gygi committed
20

21
  NameOf<T>(std::string s) : name(s) {};
Francois Gygi committed
22 23 24 25 26 27
  bool operator() (T t) const
  {
    return t->name() == name;
  }
};
#endif