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


C++ Observer类代码示例

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


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

示例1: QtilitiesCategory

Qtilities::Core::QtilitiesCategory Qtilities::CoreGui::Command::category() const {
    Observer* obs = OBJECT_MANAGER->observerReference(d_category_context);
    if (obs) {
        QVariant category_variant = obs->getMultiContextPropertyValue(this,qti_prop_CATEGORY_MAP);
        if (category_variant.isValid()) {
            return category_variant.value<QtilitiesCategory>();
        }
    }
    return QtilitiesCategory();
}
开发者ID:CJCombrink,项目名称:Qtilities,代码行数:10,代码来源:Command.cpp

示例2: getObserverById

bool GlobalAgentSubjectInterf::kill(int id)
{
    Observer * obs = getObserverById(id);
    detach(obs);

    if (!obs)
        return false;

    //if ((obs->getObserverType() != TObsMap) && (obs->getObserverType() != TObsImage))
    //    detachObserver(obs);

    switch (obs->getType())
    {
        case TObsLogFile:
           ((ObserverLogFile *)obs)->close();
            delete(ObserverLogFile *)obs;
            break;

        case TObsTable:
           ((ObserverTable *)obs)->close();
            delete(ObserverTable *)obs;
            break;

        case TObsGraphic:
        case TObsDynamicGraphic:
           ((ObserverGraphic *)obs)->close();
            delete(ObserverGraphic *)obs;
            break;

        case TObsUDPSender:
           ((ObserverUDPSender *)obs)->close();
            delete(ObserverUDPSender *)obs;
            break;

        case TObsTextScreen:
           ((ObserverTextScreen *)obs)->close();
            delete(ObserverTextScreen *)obs;
            break;

        case TObsStateMachine:
           ((ObserverStateMachine *)obs)->close();
            delete(ObserverStateMachine *)obs;
            break;

        //case TObsMap:
        //   ((AgentObserverMap *)obs)->unregistry(this);
        //    break;

        default:
            delete obs;
            break;
    }
    obs = 0;
    return true;
}
开发者ID:JoaoVitor123,项目名称:terrame,代码行数:55,代码来源:globalAgentSubjectInterf.cpp

示例3: notifyObservers

void RadiantSelectionSystem::notifyObservers(const scene::INodePtr& node, bool isComponent) {

    // Cycle through the list of observers and call the moved method
    for (ObserverList::iterator i = _observers.begin(); i != _observers.end(); ++i) {
        Observer* observer = *i;

        if (observer != NULL) {
            observer->selectionChanged(node, isComponent);
        }
    }
}
开发者ID:DerSaidin,项目名称:DarkRadiant,代码行数:11,代码来源:RadiantSelectionSystem.cpp

示例4: refreshHierarchy

void Qtilities::CoreGui::ObjectHierarchyNavigator::setNavigationStack(QStack<int> navigation_stack) {
    // First disconnect all connections to the current stack
    Observer* observer = 0;
    for (int i = 0; i < d_navigation_stack.count(); i++) {
        observer = OBJECT_MANAGER->observerReference(d_navigation_stack.at(i));
        observer->disconnect(this);
    }

    d_navigation_stack = navigation_stack;
    refreshHierarchy();
}
开发者ID:austinsc,项目名称:Qtilities,代码行数:11,代码来源:ObjectHierarchyNavigator.cpp

示例5: notifyMemberUnset

void JsonItem::notifyMemberUnset(JsonObject *object, const String *name) const
{
	const JsonItem *item = this;
	do {
		for (Observer *o = item->mObservers.first(); o; o = item->mObservers.next(o)) {
			o->memberUnset(object, name);
		}
		item = item->mParent;
	} while (item);

}
开发者ID:hhedberg,项目名称:stateplex,代码行数:11,代码来源:jsonitem.cpp

示例6: notifyObservers

void RadiantSelectionSystem::notifyObservers() {

	// Cycle through the list of observers and call the moved method
	for (ObserverList::iterator i = _observers.begin(); i != _observers.end(); i++) {
		Observer* observer = *i;

		if (observer != NULL) {
			observer->selectionChanged();
		}
	}
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:11,代码来源:RadiantSelectionSystem.cpp

示例7: notifyIncidenceDeleted

void Calendar::notifyIncidenceDeleted(Incidence *i)
{
    if(!mObserversEnabled)
        return;

    Observer *observer;
    for(observer = mObservers.first(); observer;
            observer = mObservers.next())
    {
        observer->calendarIncidenceDeleted(i);
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:12,代码来源:calendar.cpp

示例8: getObserverById

bool CellSpaceSubjectInterf::kill(int id)
{
    Observer * obs = getObserverById(id);
    detach(obs);

    if (! obs)
        return false;

    switch (obs->getType())
    {
        case TObsTextScreen:
            ((ObserverTextScreen *)obs)->close();
            delete (ObserverTextScreen *)obs;
            break;

        case TObsLogFile:
            ((ObserverLogFile *)obs)->close();
            delete (ObserverLogFile *)obs;
            break;

        case TObsTable:
            ((ObserverTable *)obs)->close();
            delete (ObserverTable *)obs;
            break;

        case TObsDynamicGraphic:
        case TObsGraphic:
            ((ObserverGraphic *)obs)->close();
            delete (ObserverGraphic *)obs;
            break;

        case TObsUDPSender:
            ((ObserverUDPSender *)obs)->close();
            delete (ObserverUDPSender *)obs;
            break;

        case TObsMap:
            ((AgentObserverMap *)obs)->close();
            delete (AgentObserverMap *)obs;
            break;

        case TObsImage:
            ((AgentObserverImage *)obs)->close();
            delete (AgentObserverImage *)obs;
            break;

        default:
            delete obs;
            break;
    }
    obs = 0;
    return true;
}
开发者ID:saraiva3,项目名称:terrame,代码行数:53,代码来源:cellSpaceSubjectInterf.cpp

示例9: CHECK

	void Timer::notifyObservers(sf::Time oldPosition, sf::Time newPosition, bool alreadySeeked)
	{
		CHECK(getStatus() != Playing, "inconsistency in timer");
		
		std::set<Observer*>::iterator it;
		for (it = m_observers.begin(); it != m_observers.end(); it++) {
			Observer* obs = *it;
			
			if (alreadySeeked)
				obs->didSeek(*this, oldPosition);
			else
				obs->willSeek(*this, newPosition);
		}
	}
开发者ID:bluekirby0,项目名称:sfeMovie,代码行数:14,代码来源:Timer.cpp

示例10: lock

//---------------------------------------------------------------------------------------
void EventsDispatcher::dispatch_next_event()
{
    pair<SpEventInfo, Observer*> event;

    {
        QueueLock lock(m_mutex);
        event = m_events.front();
        m_events.pop();
    }

    SpEventInfo pEvent = event.first;
    Observer* pObserver = event.second;
    pObserver->notify(pEvent);
}
开发者ID:lenmus,项目名称:lomse,代码行数:15,代码来源:lomse_events_dispatcher.cpp

示例11: setModified

void Calendar::setModified(bool modified)
{
    if(modified != mModified || mNewObserver)
    {
        mNewObserver = false;
        Observer *observer;
        for(observer = mObservers.first(); observer;
                observer = mObservers.next())
        {
            observer->calendarModified(modified, this);
        }
        mModified = modified;
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:14,代码来源:calendar.cpp

示例12: switch

	void Timer::notifyObservers(Status futureStatus)
	{
		std::set<Observer*>::iterator it;
		for (it = m_observers.begin(); it != m_observers.end(); it++) {
			Observer* obs = *it;
			
			switch(futureStatus) {
				case Playing:
					obs->willPlay(*this);
					break;
					
				default:
					CHECK(false, "Timer::notifyObservers() - unhandled case in switch");
			}
		}
	}
开发者ID:bluekirby0,项目名称:sfeMovie,代码行数:16,代码来源:Timer.cpp

示例13: TEST_FIXTURE

    TEST_FIXTURE(DocumentEventsTestFixture, AddHandler_CPP)
    {
        SpDocument spDoc( new MyDocument(m_libraryScope) );
        spDoc->create_empty();
        ImoParagraph* pPara = spDoc->add_paragraph();
        ImoLink* pLink = pPara->add_link("Click me");

        MyEventHandlerCPP handler;
        pLink->add_event_handler(k_on_click_event, &handler);

        MyDocument* pDoc = static_cast<MyDocument*>( spDoc.get() );
        std::list<Observer*> observers = pDoc->my_get_observers();
        CHECK( observers.size() == 1 );
        Observer* pObserver = observers.front();
        CHECK( pObserver->target() == pLink );
    }
开发者ID:lenmus,项目名称:lomse,代码行数:16,代码来源:lomse_test_events.cpp

示例14: OXFEDEAssert

void Subject::removeObserver(Observer& observer, EventID eventID) {
    _private->registerEventsIfNeeded(*this);

    size_t removalCount = 0;
    if (eventID == EventID::All) {
        for (auto& observers : _private->observers) {
            removalCount += observers.second.erase(&observer);
        }
    }
    else {
        auto observers = _private->observers.find(eventID);
        OXFEDEAssert(observers != _private->observers.end(),
                     "\nReason:\tattempted to remove an observer for an unregistered event." <<
                     "\nSubject:\t" << *this <<
                     "\nObserver:\t" << observer <<
                     "\nEvent:\t" << eventID);

        removalCount = observers->second.erase(&observer);
    }

    OXFEDEAssert(removalCount,
                 "\nReason:\tattempted to remove an observer not observing an event." <<
                 "\nSubject:\t" << *this <<
                 "\nObserver:\t" << observer <<
                 "\nEvent:\t" << eventID);

    Registration e;
    e.state = Registration::State::Unregistered;
    e.subject = this;

    for (int i = 0; i < removalCount; i++) {
        observer.onEvent(e);
    }
}
开发者ID:saldavonschwartz,项目名称:0XFEDEObserver,代码行数:34,代码来源:Subject.cpp

示例15: switch

void Qtilities::CoreGui::ObjectScopeWidget::handle_actionDetachToSelection_triggered() {
    // Get the ids of all unselected items
    QList<int> other_ids;
    int selected_id = ui->observerTable->currentItem()->type();
    for (int i = 0; i < ui->observerTable->rowCount(); i++) {
        if (selected_id != ui->observerTable->item(i,0)->type())
            other_ids << ui->observerTable->item(i,0)->type();
    }

    QStringList unsupported_items;
    for (int i = 0; i < other_ids.count(); i++) {
        Observer* observer = OBJECT_MANAGER->observerReference(other_ids.at(i));
        if (!observer)
            break;

        if (observer->displayHints()) {
            if (!(observer->displayHints()->actionHints() & ObserverHints::ActionRemoveItem)) {
                unsupported_items << observer->observerName();
            }
        } else {
            unsupported_items << observer->observerName();
        }
    }

    if (unsupported_items.count() > 0)  {
        QMessageBox msgBox;
        msgBox.setText(tr("All other contexts does not support removing of child items."));
        msgBox.setInformativeText(tr("Do you want to continue and remove the contexts which does support this?"));
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::Yes);
        int ret = msgBox.exec();

        switch (ret) {
           case QMessageBox::No:
               return;
           default:
               break;
        }
    }

    for (int i = 0; i < other_ids.count(); i++) {
        Observer* observer = OBJECT_MANAGER->observerReference(other_ids.at(i));
        if (!observer)
            break;

        if (observer->displayHints()) {
            if (observer->displayHints()->actionHints() & ObserverHints::ActionRemoveItem) {
                observer->detachSubject(d->obj);
            }
        }
    }
}
开发者ID:austinsc,项目名称:Qtilities,代码行数:52,代码来源:ObjectScopeWidget.cpp


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