#ifndef _PPA_API_H_
#define _PPA_API_H_
namespace ppa {
typedef unsigned short EventID;
typedef unsigned char GroupID;
class Base
{
public:
virtual ~Base() {}
virtual bool isEventFiltered(EventID eventId) const = 0;
virtual bool configEventById(EventID eventId, bool filtered) const = 0;
virtual int configGroupById(GroupID groupId, bool filtered) const = 0;
virtual void configAllEvents(bool filtered) const = 0;
virtual EventID registerEventByName(const char *pEventName) = 0;
virtual GroupID registerGroupByName(const char *pGroupName) = 0;
virtual EventID registerEventInGroup(const char *pEventName, GroupID groupId) = 0;
virtual void triggerStartEvent(EventID eventId) = 0;
virtual void triggerEndEvent(EventID eventId) = 0;
virtual void triggerTidEvent(EventID eventId, unsigned int data) = 0;
virtual void triggerDebugEvent(EventID eventId, unsigned int data0, unsigned int data1) = 0;
virtual EventID getEventId(int index) const = 0;
protected:
virtual void init(const char **pNames, int eventCount) = 0;
};
extern ppa::Base *ppabase;
struct ProfileScope
{
ppa::EventID id;
ProfileScope(int e) { if (ppabase) { id = ppabase->getEventId(e); ppabase->triggerStartEvent(id); } else id = 0; }
~ProfileScope() { if (ppabase) ppabase->triggerEndEvent(id); }
};
}
#endif