/usr/include/CLAM/ProcessingDataPlugin.hxx is in libclam-dev 1.4.0-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | #ifndef ProcessingDataPlugin_hxx
#define ProcessingDataPlugin_hxx
#include <string>
#include <cstdlib>
#include <map>
#include <list>
#include <typeinfo>
#include <iostream>
#ifdef __GNUC__
#include <cxxabi.h>
#endif//__GNUC__
namespace CLAM
{
class ProcessingDataPlugin
{
public:
typedef std::string Key;
typedef std::type_info Type;
typedef std::map<Key,ProcessingDataPlugin *> TypeMap;
private:
const Type & _type;
std::string _color;
std::string _displayName;
std::string _name;
static std::string demangle(const std::string & mangledName)
{
std::string result = mangledName;
#ifdef __GNUC__
int demangleError = 0;
char * demangled = abi::__cxa_demangle(mangledName.c_str(),0,0,&demangleError);
if (!demangleError && demangled)
result = demangled;
if (demangled) free(demangled);
#endif//__GNUC__
return result;
}
ProcessingDataPlugin(const std::type_info & type, const std::string & color, const std::string & displayName)
: _type(type)
, _color(color)
{
_name = _displayName = type.name();
_displayName = displayName.empty()?
demangle(_name) : displayName;
// std::cout << "Adding TypePlugin " << _name << " shown as " << _displayName << " with color " << color << std::endl;
getTypeMap().insert(std::make_pair(_name, this));
}
~ProcessingDataPlugin()
{
if (lookUp(_type)==this) getTypeMap().erase(_type.name());
}
public:
const std::string & color() const { return _color; }
const std::string & name() const { return _name; }
const std::string & displayName() const { return _displayName; }
private:
static TypeMap & getTypeMap();
public:
static std::list<std::string> types()
{
std::list<std::string> result;
for (TypeMap::iterator it=getTypeMap().begin();
it!=getTypeMap().end(); it++)
{
result.push_back(it->first);
}
return result;
}
static ProcessingDataPlugin * lookUp(const Type & type)
{
TypeMap::iterator it = getTypeMap().find(type.name());
if (it==getTypeMap().end()) return 0;
return it->second;
}
static std::string colorFor(const std::type_info & type)
{
CLAM::ProcessingDataPlugin * plugin = lookUp(type);
if (plugin) return plugin->color();
return "";
}
static std::string displayNameFor(const std::type_info & type)
{
CLAM::ProcessingDataPlugin * plugin = lookUp(type);
if (plugin) return plugin->displayName();
return demangle(type.name());
}
public:
template <typename DataType>
class Registrator
{
ProcessingDataPlugin * _plugin;
public:
Registrator(const std::string & color, const std::string & displayName="")
: _plugin( new ProcessingDataPlugin(typeid(DataType), color, displayName))
{
}
~Registrator() { delete _plugin; }
};
};
}
#endif//ProcessingDataPlugin_hxx
|