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


C++ NotificationCenter类代码示例

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


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

示例1: INC_STATS

v8::Handle<v8::Value> V8NotificationCenter::requestPermissionCallback(const v8::Arguments& args)
{
    INC_STATS(L"DOM.NotificationCenter.RequestPermission()");
    NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args.Holder());
    ScriptExecutionContext* context = notificationCenter->context();

    // Make sure that script execution context is valid.
    if (!context)
        return throwError(INVALID_STATE_ERR);

    // Requesting permission is only valid from a page context.
    if (context->isWorkerContext())
        return throwError(NOT_SUPPORTED_ERR);

    RefPtr<V8CustomVoidCallback> callback;
    if (args.Length() > 0) {
        if (!args[0]->IsObject())
            return throwError("Callback must be of valid type.", V8Proxy::TypeError);
 
        callback = V8CustomVoidCallback::create(args[0], context);
    }

    notificationCenter->requestPermission(callback.release());
    return v8::Undefined();
}
开发者ID:achellies,项目名称:WinCEWebKit,代码行数:25,代码来源:V8NotificationCenterCustom.cpp

示例2: assert

void NotificationCenterTest::test2()
{
	NotificationCenter nc;
	nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
	nc.postNotification(new Notification);
	assert (_set.size() == 1);
	assert (_set.find("handle1") != _set.end());
	nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
}
开发者ID:RangelReale,项目名称:sandbox,代码行数:9,代码来源:NotificationCenterTest.cpp

示例3: WindowProc

	LRESULT CALLBACK WindowProc(HWND hwnd,  UINT uMsg, 	WPARAM wParam, LPARAM lParam ){
		if( uMsg==WM_NOTIFICATION ){
			NotificationCenter* nc = (NotificationCenter*) wParam;
			Notification* notify = (Notification*) lParam;
			if( nc )
				nc->displayNotification(notify);
			if( notify ) delete notify;
			return 0;
		}
		return ::DefWindowProcA(hwnd, uMsg, wParam, lParam);
	}
开发者ID:iwzoo,项目名称:Win32-Notification-Center,代码行数:11,代码来源:notification.cpp

示例4: INC_STATS

v8::Handle<v8::Value> V8NotificationCenter::createNotificationCallback(const v8::Arguments& args)
{
    INC_STATS(L"DOM.NotificationCenter.CreateNotification()");
    NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args.Holder());

    ExceptionCode ec = 0;
    RefPtr<Notification> notification = notificationCenter->createNotification(toWebCoreString(args[0]), toWebCoreString(args[1]), toWebCoreString(args[2]), ec);

    if (ec)
        return throwError(ec);

    return toV8(notification.get());
}
开发者ID:ShouqingZhang,项目名称:webkitdriver,代码行数:13,代码来源:V8NotificationCenterCustom.cpp

示例5: main

// 중재자(Mediator) 패턴
// - 복잡한 객체간의 관계를 단순화 시켜주는 클래스
int main()
{
  NotificationCenter& globalCenter = NotificationCenter::defaultCenter();

  NotificationCenter nc;
  nc.addObserver("LOWBATTERY", &foo);
  nc.addObserver("LOWBATTERY", bind(&goo, 5));

  Dialog dialog;
  nc.addObserver("LOWBATTERY", bind(&Dialog::warning, &dialog));


  // 이제 배터리를 체크하는 모듈에서
  nc.postNotificationWithName("LOWBATTERY");
}
开发者ID:goodgodgd,项目名称:DesignPatternCpp,代码行数:17,代码来源:3_통보센터.cpp

示例6: main_1

int main_1(int argc, char** argv) {

    NotificationCenter nc;
    Target target;

    // Observer works with plain pointers to Notification objects.
    nc.addObserver(
        Observer<Target, BaseNotification>(target, &Target::handleBase));
    // NObserver works with AutoPtr<Notification>.
    // handleBase and handleSub both got this
    nc.addObserver(
        NObserver<Target, SubNotification>(target, &Target::handleSub));

    std::cout << "* postNotification: BaseNotification" << std::endl;
    nc.postNotification(new BaseNotification("Base Class Notification"));

    // Targets subscribed for a particular notification class also receive
    // notifications that are subclasses of that class.
    std::cout << "* postNotification: SubNotification" << std::endl;
    nc.postNotification(new SubNotification("Sub Class Notification"));

    nc.removeObserver(
        Observer<Target, BaseNotification>(target, &Target::handleBase));
    nc.removeObserver(
        NObserver<Target, SubNotification>(target, &Target::handleSub));

    return 0;
}
开发者ID:ricleal,项目名称:CppPocoTests,代码行数:28,代码来源:poco.cpp

示例7: dispatch

void PriorityNotificationQueue::dispatch(NotificationCenter& notificationCenter)
{
    FastMutex::ScopedLock lock(_mutex);
    Notification::Ptr pNf = dequeueOne();
    while (pNf)
    {
        notificationCenter.postNotification(pNf);
        pNf = dequeueOne();
    }
}
开发者ID:as2120,项目名称:ZPoco,代码行数:10,代码来源:PriorityNotificationQueue.cpp

示例8: handleNotificationEvent

int LuaEngine::handleNotificationEvent(void* data)
{
    if ( NULL == data)
        return 0;

    BasicScriptData* basicScriptData = (BasicScriptData*)(data);
    if (NULL == basicScriptData->nativeObject ||NULL == basicScriptData->value)
        return 0;

    NotificationCenter* center = static_cast<NotificationCenter*>(basicScriptData->nativeObject);

    int handler = center->getObserverHandlerByName((const char*)basicScriptData->value);

    if (0 == handler)
        return 0;

    _stack->pushString((const char*)basicScriptData->value);
    int ret = _stack->executeFunctionByHandler(handler, 1);
    _stack->clean();
    return ret;
}
开发者ID:CBanDa,项目名称:cocos2d-x-3.0alpha0-pre,代码行数:21,代码来源:CCLuaEngine.cpp

示例9: assert

void NotificationCenterTest::test3()
{
	NotificationCenter nc;
	nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
	nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
	assert (nc.hasObservers());
	assert (nc.countObservers() == 2);
	nc.postNotification(new Notification);
	assert (_set.size() == 2);
	assert (_set.find("handle1") != _set.end());
	assert (_set.find("handle2") != _set.end());
	nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
	nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
	assert (!nc.hasObservers());
	assert (nc.countObservers() == 0);
}
开发者ID:Victorcasas,项目名称:georest,代码行数:16,代码来源:NotificationCenterTest.cpp

示例10: dispatch

	void MessageQueue::dispatch(NotificationCenter& center, unsigned int maxNumberToDispatch)
	{
		MessagesIterator iter;
		unsigned int dispatchCount;

		Poco::ScopedRWLock lock(dispatchQueueRWLock, true);

		dispatchCount = 0;

		// First copy the messages from the queuedMessages queue to the dispatchQueue
		queuedMessagesRWLock.writeLock();
		iter = queuedMessages.begin();
		while ((iter != queuedMessages.end()) && ((maxNumberToDispatch == 0) || (dispatchCount < maxNumberToDispatch)))
		{
			// Insert message into dispatch queue
			dispatchQueue.push_back(*iter);

			// Remove message from queued messages queue
			iter = queuedMessages.erase(iter);

			dispatchCount++;
		}
		queuedMessages.clear();
		queuedMessagesRWLock.unlock();

		// Dispatch the messages
		for (iter = dispatchQueue.begin(); iter != dispatchQueue.end(); )
		{

			// Call duplicate on the Message instance, since Poco doesn't expect the object to be shared
			(*iter)->duplicate();

			// Send the message
			center.postNotification(*iter);

			// Remove the message from the list
			iter = dispatchQueue.erase(iter);
		}
		dispatchQueue.clear();
	}
开发者ID:mchamberlain,项目名称:asd-ve-platform,代码行数:40,代码来源:MessageQueue.cpp

示例11: Init

	void NotificationView::Init(NotificationCenter & center)
	{
		auto model = std::make_shared<NotificationModel>(center.GetStore());
		SetModel(std::move(model));
	}
开发者ID:dmlys,项目名称:QtTools,代码行数:5,代码来源:NotificationView.cpp

示例12:

void NotificationCenterTest::test1()
{
	NotificationCenter nc;
	nc.postNotification(new Notification);
}
开发者ID:RangelReale,项目名称:sandbox,代码行数:5,代码来源:NotificationCenterTest.cpp

示例13: o1

void NotificationCenterTest::test4()
{
	NotificationCenter nc;
	Observer<NotificationCenterTest, Notification> o1(*this, &NotificationCenterTest::handle1);
	Observer<NotificationCenterTest, Notification> o2(*this, &NotificationCenterTest::handle2);
	nc.addObserver(o1);
	assert (nc.hasObserver(o1));
	nc.addObserver(o2);
	assert (nc.hasObserver(o2));
	nc.postNotification(new Notification);
	assert (_set.size() == 2);
	assert (_set.find("handle1") != _set.end());
	assert (_set.find("handle2") != _set.end());
	nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
	assert (!nc.hasObserver(o1));
	nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle2));
	assert (!nc.hasObserver(o2));
	_set.clear();
	nc.postNotification(new Notification);
	assert (_set.empty());
	Observer<NotificationCenterTest, Notification> o3(*this, &NotificationCenterTest::handle3);
	nc.addObserver(o3);
	assert (nc.hasObserver(o3));
	nc.postNotification(new Notification);
	assert (_set.size() == 1);
	assert (_set.find("handle3") != _set.end());
	nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle3));
	assert (!nc.hasObserver(o3));
}
开发者ID:Chingliu,项目名称:poco,代码行数:29,代码来源:NotificationCenterTest.cpp

示例14: logError

Observer::~Observer() {
  NotificationCenter *nc = NotificationCenter::get();
  if (nc->is_registered(this))
    logError("Notifications: Observer %p was deleted while still listening for notifications.\n", this);
}
开发者ID:pk-codebox-evo,项目名称:mysql-workbench,代码行数:5,代码来源:notifications.cpp


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