本文整理汇总了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();
}
示例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;
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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();
}
}
}
示例7: notifyIncidenceDeleted
void Calendar::notifyIncidenceDeleted(Incidence *i)
{
if(!mObserversEnabled)
return;
Observer *observer;
for(observer = mObservers.first(); observer;
observer = mObservers.next())
{
observer->calendarIncidenceDeleted(i);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
}
示例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");
}
}
}
示例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 );
}
示例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);
}
}
示例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);
}
}
}
}