当前位置: 首页>>代码示例>>C++>>正文


C++ EventType::getId方法代码示例

本文整理汇总了C++中EventType::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ EventType::getId方法的具体用法?C++ EventType::getId怎么用?C++ EventType::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventType的用法示例。


在下文中一共展示了EventType::getId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addListener

// Adds an event listener to the list for that event type. Returns false if listener is not added, true if added
bool EventManager::addListener(EventListenerPtr const & listener, EventType const & type)
{
	if (!validateType(type))
		return false;

	EventTypeSet::iterator it = m_eventTypes.find(type);

	// Looks to see if the event is a type seen before and adds the event type if not.
	if (it == m_eventTypes.end())
	{
		EventTypeSetRet itEvent = m_eventTypes.insert(type);

		if (itEvent.second == false)
			return false;

		if (itEvent.first == m_eventTypes.end())
			return false;

		it = itEvent.first;
	}

	EventListenerMap::iterator itMap = m_listenerMap.find(type.getId());

	// Finds the list of listeners for the event type and creates one if it doesn't exist.
	if (itMap == m_listenerMap.end())
	{
		EventListenerMapRet itListMap = m_listenerMap.insert(EventListenerMapEntry(type.getId(), EventListenerList()));
		
		if (itListMap.second == false)
			return false;

		if (itListMap.first == m_listenerMap.end())
			return false;

		itMap = itListMap.first;
	}

	EventListenerList & theList= (*itMap).second;

	// Checks to see if the listener is already in the map.
	for (EventListenerList::iterator i = theList.begin(); i != theList.end(); i++)
	{
		if ((*i) == listener)
			return false;
	}

	theList.push_back(listener);

	return true;
}
开发者ID:charlie-a-maxwell,项目名称:TowerDefense,代码行数:51,代码来源:Event.cpp

示例2: validateType

// Checks if type is valid. Does this by finding the hash value of the name
// and then checking if the names match if that hash number is already taken.
bool EventManager::validateType(EventType const & type)
{
	if (type.getName() == NULL)
		return false;

	if (type.getId() == 0)
		return false;

	EventTypeSet::iterator it = m_eventTypes.find(type);

	if (it != m_eventTypes.end())
	{
		EventType known = (*it);
		char * const oldName = known.getName();
		char * const newName = type.getName();

		int check = strcmp(oldName, newName);

		assert(check==0 && "Event types hashed wrong!");

		if (check!=0)
			return false;
	}

	return true;
}
开发者ID:charlie-a-maxwell,项目名称:TowerDefense,代码行数:28,代码来源:Event.cpp

示例3: tick

// Goes through the event queue and processes events for the given time.
bool EventManager::tick(unsigned int maxMS)
{
	unsigned int curTick = GetTickCount();
	unsigned int maxTime = maxMS + curTick;

	bool processed = false;

	while (m_eventQueue.size() > 0)
	{
		EventPtr event = m_eventQueue.front();
		m_eventQueue.pop_front();

		EventType type = event->getType();
		EventListenerMap::iterator itMap = m_listenerMap.find(type.getId());

		if (itMap == m_listenerMap.end())
			continue;

		EventListenerList theList = (*itMap).second;

		for (EventListenerList::iterator i = theList.begin(); i != theList.end(); i++)
		{
			if ((*i)->HandleEvent(*event))
				break;
		}

		curTick = GetTickCount();
		if (curTick >= maxTime)
			break;
	}
	return processed;
}
开发者ID:charlie-a-maxwell,项目名称:TowerDefense,代码行数:33,代码来源:Event.cpp

示例4: queueEvent

// Adds event to event queue. Returns true if added.
bool EventManager::queueEvent(EventPtr const & event)
{
	EventType type = event->getType();

	if (!validateType(type))
		return false;

	EventListenerMap::iterator itMap = m_listenerMap.find(type.getId());
	if (itMap == m_listenerMap.end())
		return false;

	m_eventQueue.push_back(event);
	return true;
}
开发者ID:charlie-a-maxwell,项目名称:TowerDefense,代码行数:15,代码来源:Event.cpp

示例5: main

int main(int argc, char* argv[]) {

    if (argc < 4) {
        std::cerr << "Usage: " << argv[0] << " <application-key> <username> <password>" << std::endl;
        return 1;
    }

    ExchangeApi exchangeApi(argv[1]);

    if (exchangeApi.login(argv[2], argv[3])) {

        MarketFilter filter;
        ListEventTypesRequest req(filter);

        if (req.isValid()) {
            ListEventTypesResponse resp = exchangeApi.listEventTypes(req);

            if (resp.isSuccess()) {

                std::vector<EventTypeResult> eventTypeResults = resp.getEventTypeResults();
                for (unsigned i = 0; i < eventTypeResults.size(); ++i) {
                    EventTypeResult etr = eventTypeResults[i];
                    EventType et = etr.getEventType();
                    std::cout << et.getId() << " " << et.getName() << std::endl;
                }

            } else {
                std::cout << "request failed: " << resp.getFaultCode() << " " << resp.getFaultString() << std::endl;
            }
        } else {
            std::cout << "invalid request: " << req.toString() << std::endl;
        }

    } else {
        std::cout << "failed to log in" << std::endl;
    }

}
开发者ID:captain-igloo,项目名称:greentop,代码行数:38,代码来源:listEventTypes.cpp

示例6: triggerEvent

// Instantly triggers an event. Returns true if event is processed
bool EventManager::triggerEvent(Event const & event)
{
	EventType type = event.getType();

	if (!validateType(type))
		return false;

	EventListenerMap::iterator itMap = m_listenerMap.find(type.getId());

	if (itMap == m_listenerMap.end())
		return false;

	EventListenerList theList = (*itMap).second;

	bool processed = false;

	for (EventListenerList::iterator i = theList.begin(); i != theList.end(); i++)
	{
		if ((*i)->HandleEvent(event))
			processed = true;
	}

	return processed;
}
开发者ID:charlie-a-maxwell,项目名称:TowerDefense,代码行数:25,代码来源:Event.cpp


注:本文中的EventType::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。