|
#ifndef IconBroker_H
#define IconBroker_H
#include <Model/CppTagModel.h>
#include <Renderer/IconDescriptor.h>
#include <map>
template<typename Icon>
class IconBroker
{
protected:
typedef std::map<CppTagType, std::map<size_t, Icon> > IconMap;
private:
IconMap mIcons;
public:
Icon getIcon(CppTagType type)
{
return mIcons[type][0];
}
Icon getIcon(const CppTag &tag, bool undecorated = false)
{
IconDescriptor descriptor;
const_cast<CppTag&>(tag).acceptVisitor(&descriptor);
return undecorated ? getIcon(descriptor.type) : getIcon(descriptor);
}
Icon getIcon(const IconDescriptor &descriptor)
{
CppTagType type = descriptor.type;
size_t mask = descriptor.decorators.hash();
map<size_t, Icon>::iterator image = mIcons[type].find(mask);
if(image == mIcons[type].end()) {
mIcons[type][mask] = createIcon(descriptor);
}
return mIcons[type][mask];
}
protected:
void initialize(const IconMap &icons)
{
mIcons = icons;
}
private:
virtual Icon createIcon(const IconDescriptor&) = 0;
};
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.