コード例 #1
0
ファイル: net_device_entry.cpp プロジェクト: dinal/libvma
void net_device_entry::handle_timer_expired(void* user_data)
{
	NOT_IN_USE(user_data);
	auto_unlocker lock(m_lock);
	net_device_val* p_ndv = dynamic_cast<net_device_val*>(m_val);
	if (p_ndv) {
		if(m_bond == net_device_val::ACTIVE_BACKUP) {
			if(p_ndv->update_active_backup_slaves()) {
				//active slave was changed
				notify_observers();
			}
		} else if(m_bond == net_device_val::LAG_8023ad){
			if(p_ndv->update_active_slaves()) {
				//slave state was changed
				g_p_event_handler_manager->unregister_timer_event(this, m_timer_handle);
				m_timer_handle = g_p_event_handler_manager->register_timer_event(SLAVE_CHECK_TIMER_PERIOD_MSEC, this, PERIODIC_TIMER, 0);
				notify_observers();
			} else {
				if (timer_count >= 0) {
					timer_count++;
					if (timer_count == SLAVE_CHECK_FAST_NUM_TIMES) {
						timer_count = -1;
						g_p_event_handler_manager->unregister_timer_event(this, m_timer_handle);
						m_timer_handle = g_p_event_handler_manager->register_timer_event(SLAVE_CHECK_TIMER_PERIOD_MSEC, this, PERIODIC_TIMER, 0);
					}
				}
			}
		}
	}
}
コード例 #2
0
		virtual void set_item_model(i_item_model& aItemModel)
		{
			if (iModel == &aItemModel)
				return;
			if (has_item_model())
				item_model().unsubscribe(*this);
			unset_current_index();
			i_item_model* oldModel = iModel;
			iModel = &aItemModel;
			item_model().subscribe(*this);
			if (oldModel == 0)
				notify_observers(i_item_selection_model_subscriber::NotifyItemModelAdded, item_model());
			else
				notify_observers(i_item_selection_model_subscriber::NotifyItemModelChanged, item_model(), *oldModel);
		}
コード例 #3
0
		virtual void set_mode(item_selection_mode aMode)
		{
			if (iMode == aMode)
				return;
			iMode = aMode;
			notify_observers(i_item_selection_model_subscriber::NotifySelectionModeChanged, mode());
		}
コード例 #4
0
ファイル: settings.hpp プロジェクト: AndreasMartin72/neolib
		virtual void setting_changed(i_setting& aExistingSetting)
		{
			setting_list::iterator iter = iSettings.find(setting::key_type(aExistingSetting.id()));
			if (iter == iSettings.end())
				throw setting_not_found();
			notify_observers(i_subscriber::NotifySettingChanged, *iter);
		}
コード例 #5
0
ファイル: reuse_bind_key.cpp プロジェクト: jrwilson/ioa
 void bound (const ioa::bound_t result) {
   switch (result) {
   case ioa::BIND_KEY_EXISTS_RESULT:
     assert (false);
   case ioa::OUTPUT_AUTOMATON_DNE_RESULT:
     assert (false);
     break;
   case ioa::INPUT_AUTOMATON_DNE_RESULT:
     assert (false);
     break;
   case ioa::BINDING_EXISTS_RESULT:
     assert (false);
     break;
   case ioa::OUTPUT_ACTION_UNAVAILABLE_RESULT:
     assert (false);
     break;
   case ioa::INPUT_ACTION_UNAVAILABLE_RESULT:
     assert (false);
     break;
   case ioa::BOUND_RESULT:
     // Okay.
     m_bound = true;
     notify_observers ();
     break;
   }
 }
コード例 #6
0
ファイル: Enemy.cpp プロジェクト: stewartmatheson/Melbourne
void Enemy::step()
{
    //body->ApplyForce(b2Vec2(.0f, .0f), b2Vec2(.0f, .0f));
    b2Vec2 f = b2Vec2(target->get_x_position(), target->get_y_position());
    b2Vec2 p = body->GetWorldPoint(b2Vec2(0.0f, 0.0f));
    body->ApplyForce(f, p);
    notify_observers();
}
コード例 #7
0
		virtual void set_current_index(const item_model_index& aIndex)
		{
			if (iCurrentIndex == aIndex)
				return;
			optional_item_model_index previousIndex = iCurrentIndex;
			iCurrentIndex = aIndex;
			notify_observers(i_item_selection_model_subscriber::NotifyCurrentIndexChanged, iCurrentIndex, previousIndex);
			current_index_changed.trigger(iCurrentIndex, previousIndex);
		}
コード例 #8
0
		virtual void unset_current_index()
		{
			if (iCurrentIndex == boost::none)
				return;
			optional_item_model_index previousIndex = iCurrentIndex;
			iCurrentIndex = boost::none;
			notify_observers(i_item_selection_model_subscriber::NotifyCurrentIndexChanged, iCurrentIndex, previousIndex);
			current_index_changed.trigger(iCurrentIndex, previousIndex);
		}
コード例 #9
0
ファイル: settings.hpp プロジェクト: AndreasMartin72/neolib
		virtual void delete_setting(i_setting& aExistingSetting)
		{
			setting_list::iterator iter = iSettings.find(setting::key_type(aExistingSetting.id()));
			if (iter == iSettings.end())
				throw setting_not_found();
			notify_observers(i_subscriber::NotifySettingDeleted, *iter);
			iSettings.erase(iter);
			save();
		}
コード例 #10
0
ファイル: notify.cpp プロジェクト: FlibbleMr/neoirc
	bool notify::add(const notify_entry& aEntry)
	{
		for (container_type::iterator i = iEntries.begin(); i != iEntries.end(); ++i)
			if (**i == aEntry)
				return false;
		iEntries.push_back(notify_entry_ptr(new notify_entry(aEntry)));
		if (!iLoading)
			notify_observers(notify_list_observer::NotifyAdded, *iEntries.back());
		return true;
	}
コード例 #11
0
ファイル: notify.cpp プロジェクト: FlibbleMr/neoirc
	void notify::remove(const notify_entry& aEntry)
	{
		for (container_type::iterator i = iEntries.begin(); i != iEntries.end(); ++i)
			if (&**i == &aEntry)
			{
				notify_entry_ptr temp = *i;
				iEntries.erase(i);
				notify_observers(notify_list_observer::NotifyRemoved, *temp);
				break;
			}
	}
コード例 #12
0
ファイル: netlink_wrapper.cpp プロジェクト: Cai900205/test
void netlink_wrapper::link_cache_callback(nl_cache* , nl_object* obj, int)
{
	nl_logfunc( "---> link_cache_callback");
	struct rtnl_link* link = (struct rtnl_link*) obj;
	link_nl_event new_event(g_nl_rcv_arg.msghdr, link, g_nl_rcv_arg.netlink);

	notify_observers(&new_event, nlgrpLINK);

	g_nl_rcv_arg.msghdr = NULL;
	nl_logfunc( "<--- link_cache_callback");
}
コード例 #13
0
ファイル: Player.cpp プロジェクト: stewartmatheson/Melbourne
void Player::step()
{
    if(energy < 0)
        kill();
        
    if(energy < 100 && energy_timer.GetElapsedTime() > charge_rate)
    {
        energy++;
        energy_timer.Reset();
    }
    notify_observers();
}
コード例 #14
0
ファイル: netlink_wrapper.cpp プロジェクト: Cai900205/test
void netlink_wrapper::neigh_cache_callback(nl_cache* , nl_object* obj, int)
{
	nl_logfunc( "---> neigh_cache_callback");
	struct rtnl_neigh* neigh = (struct rtnl_neigh*)obj;
	neigh_nl_event new_event(g_nl_rcv_arg.msghdr, neigh, g_nl_rcv_arg.netlink);

	notify_observers(&new_event, nlgrpNEIGH);

	g_nl_rcv_arg.msghdr = NULL;
	nl_logfunc( "<--- neigh_cache_callback");

}
コード例 #15
0
ファイル: settings.hpp プロジェクト: AndreasMartin72/neolib
		virtual void apply_changes()
		{
			if (!dirty())
				return;
			std::set<string> categoriesChanged;
			for (setting_list::iterator iter = iSettings.begin(); iter != iSettings.end(); ++iter)
				if (iter->apply_change())
					categoriesChanged.insert(iter->category());
			for (std::set<string>::const_iterator iter = categoriesChanged.begin(); iter != categoriesChanged.end(); ++iter)
				notify_observers(i_subscriber::NotifySettingsChanged, *iter);
			save();
		}
コード例 #16
0
ファイル: docs.cpp プロジェクト: imeteora/aseprite
void Docs::remove(Doc* doc)
{
  iterator it = std::find(begin(), end(), doc);
  if (it == end())              // Already removed.
    return;

  m_docs.erase(it);

  notify_observers(&DocsObserver::onRemoveDocument, doc);

  doc->setContext(NULL);
}
コード例 #17
0
ファイル: environment.cpp プロジェクト: NickDaniil/structured
 bool StoredEnvironment::set_value(
     const std::string& name, const std::string& value
 ) {
     for(unsigned int i=0; i<environments_.size(); i++) {
         if(environments_[i]->set_value(name,value)) {
             return true ;
         }
     }
     values_[name] = value ;
     notify_observers(name) ;
     return true ;
 }
コード例 #18
0
ファイル: binding_manager.hpp プロジェクト: jrwilson/ioa
    void unbound (const unbound_t result) {
      switch (result) {
      case BIND_KEY_DNE_RESULT:
	// System is incorrect.
	assert (false);
	break;
      case UNBOUND_RESULT:
	m_state = UNBOUND;
	notify_observers ();
	delete this;
      }
    }
コード例 #19
0
ファイル: route_entry.cpp プロジェクト: Cai900205/test
void route_entry::notify_cb()
{
	// got addr_change event from net_device_entry --> does not change the validity of route_entry!
	rt_entry_logdbg("");
	if (m_p_net_dev_entry->is_valid()) {
		m_p_net_dev_entry->get_val(m_p_net_dev_val);
	}
	else {
		m_p_net_dev_val = NULL;
	}
	notify_observers();
}
コード例 #20
0
ファイル: graph.cpp プロジェクト: ffhaddad/Graph
bool Graph::add_vertex(const Vertex *vertex)
{
  const std::string F("add_vertex");

  // null vertices not allowed
  if (vertex == nullptr) {
    notify_observers(
      Message(MsgID::WARNING, F, "null vertex is unsupported")
      );

    return false;
  }

  _writer_lock();

  // duplicate verticies not allowed
  if (!_vertices.insert(vertex).second)
  {
    notify_observers(
      Message(MsgID::WARNING, F,
      "vertex " + vertex->get_name() + " already added")
      );

    _writer_unlock();
    return false;
  }

  // each vertex holds two sets.  one for all directed edges and the other for
  // the purpose of finding indegree.
  _directed_edges.insert(std::make_pair(vertex, new VertexSet));
  _reverse_edges.insert(std::make_pair(vertex, new VertexSet));

  notify_observers(
    Message(MsgID::INFO, F, "vertex " + vertex->get_name() + " added")
    );

  _writer_unlock();
  return true;
}
コード例 #21
0
ファイル: docs.cpp プロジェクト: imeteora/aseprite
Doc* Docs::add(Doc* doc)
{
  ASSERT(doc != NULL);
  ASSERT(doc->id() != doc::NullId);

  if (doc->context() != m_ctx) {
    doc->setContext(m_ctx);
    ASSERT(std::find(begin(), end(), doc) != end());
    return doc;
  }

  m_docs.insert(begin(), doc);

  notify_observers(&DocsObserver::onAddDocument, doc);
  return doc;
}
コード例 #22
0
ファイル: reuse_bind_key.cpp プロジェクト: jrwilson/ioa
  void unbound (const ioa::unbound_t result) {
    switch (result) {
    case ioa::BIND_KEY_DNE_RESULT:
      assert (false);
      break;
    case ioa::UNBOUND_RESULT:
      // Okay.
      m_bound = false;
      ++m_unbound_count;
      notify_observers ();
      if (m_unbound_count == 2) {
	delete this;
      }
      break;
    }
  }
コード例 #23
0
ファイル: netlink_wrapper.cpp プロジェクト: Cai900205/test
void netlink_wrapper::route_cache_callback(nl_cache* , nl_object* obj, int)
{
	nl_logfunc( "---> route_cache_callback");
	struct rtnl_route* route = (struct rtnl_route*) obj;
	route_nl_event new_event(g_nl_rcv_arg.msghdr, route,g_nl_rcv_arg.netlink);
	// notify only route events of main table
	const netlink_route_info* info =  new_event.get_route_info();
	if (info->table == ROUTE_MAIN_TABLE_ID) {
		notify_observers(&new_event, nlgrpROUTE);
	}
	else {
		nl_logfunc("ROUTE events from non-main route table are filtered: table_id=%d", info->table);
	}
	g_nl_rcv_arg.msghdr = NULL;
	nl_logfunc( "<--- route_cache_callback");
}
コード例 #24
0
ファイル: docs.cpp プロジェクト: imeteora/aseprite
Doc* Docs::add(int width, int height, ColorMode mode, int ncolors)
{
  // Ask to observers to create the document (maybe a doc::Document or
  // a derived class).
  CreateDocArgs args;
  notify_observers(&DocsObserver::onCreateDocument, &args);
  if (!args.document())
    args.setDocument(new Doc(nullptr));

  std::unique_ptr<Doc> doc(args.document());
  doc->sprites().add(width, height, mode, ncolors);
  doc->setFilename("Sprite");
  doc->setContext(m_ctx); // Change the document context to add the doc in this collection

  return doc.release();
}
コード例 #25
0
ファイル: graph.cpp プロジェクト: ffhaddad/Graph
Graph::size_type Graph::outdegree(const Vertex *vertex) const
{
  _reader_lock();
  const std::string F("outdegree");

  if (_vertices.find(vertex) == _vertices.cend())
  {
    notify_observers(Message(
      MsgID::ERROR,
      F,
      "vertex " + vertex->get_name() + " does not exist in graph")
      );

    _reader_unlock();
    return 0;
  }

  size_type size = _directed_edges.find(vertex)->second->size();

  _reader_unlock();
  return size;
}
コード例 #26
0
ファイル: binding_manager.hpp プロジェクト: jrwilson/ioa
    void bound (const bound_t result) {
      switch (result) {
      case BIND_KEY_EXISTS_RESULT:
	// System is incorrect.
	assert (false);
	break;
      case OUTPUT_AUTOMATON_DNE_RESULT:
	m_state = OUTPUT_AUTOMATON_DNE;
	notify_observers ();
	delete this;
	break;
      case INPUT_AUTOMATON_DNE_RESULT:
	m_state = INPUT_AUTOMATON_DNE;
	notify_observers ();
	delete this;
	break;
      case BINDING_EXISTS_RESULT:
	m_state = BINDING_EXISTS;
	notify_observers ();
	delete this;
	break;
      case INPUT_ACTION_UNAVAILABLE_RESULT:
	m_state = INPUT_ACTION_UNAVAILABLE;
	notify_observers ();
	delete this;
	break;
      case OUTPUT_ACTION_UNAVAILABLE_RESULT:
	m_state = OUTPUT_ACTION_UNAVAILABLE;
	notify_observers ();
	delete this;
	break;
      case BOUND:
	m_state = BOUND;
	notify_observers ();
	break;
      }
    }
コード例 #27
0
ファイル: test_observer.cpp プロジェクト: Qbicz/etl
  //*********************************
  // Notify all of the observers.
  //*********************************
	void send_notifications()
	{
		notify_observers(data1);
    notify_observers(data2);
	}
コード例 #28
0
ファイル: test_observer.cpp プロジェクト: Qbicz/etl
    //*********************************
    // Notify all of the observers.
    //*********************************
	void send_notifications()
	{
    notify_observers(data3);
	}
コード例 #29
0
ファイル: observable.hpp プロジェクト: AndreasMartin72/neolib
		void notify_observers(notify_type aType, const T1& aParameter, const T2& aParameter2)
		{
			notify_observers(aType, static_cast<const void*>(&aParameter), static_cast<const void*>(&aParameter2));
		}
コード例 #30
0
ファイル: observable.hpp プロジェクト: AndreasMartin72/neolib
		void notify_observers(notify_type aType, const T& aParameter) const
		{
			notify_observers(aType, static_cast<const void*>(&aParameter));
		}