Exemple #1
0
void Movie::LinkButton()
{
	if (!visible || !active || !hasButton)
		return;

	for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
		Object *obj = m_displayList[dlDepth].get();
		if (obj) {
			if (obj->IsButton()) {
				((Button *)obj)->LinkButton();
			} else if (obj->IsMovie()) {
				Movie *movie = (Movie *)obj;
				if (movie->hasButton)
					movie->LinkButton();
			}
		}
	}

	if (!m_attachedMovies.empty()) {
		AttachedMovieList::iterator it(m_attachedMovieList.begin()),
			itend(m_attachedMovieList.end());
		for (; it != itend; ++it)
			if (it->second && it->second->hasButton)
				it->second->LinkButton();
	}

	if (!m_attachedLWFs.empty()) {
		AttachedLWFList::iterator
			it(m_attachedLWFList.begin()), itend(m_attachedLWFList.end());
		for (; it != itend; ++it)
			if (it->second)
				it->second->LinkButton();
	}
}
Exemple #2
0
Button *Movie::SearchButtonInstance(string instanceName, bool recursive) const
{
	int stringId = lwf->GetStringId(instanceName);
	if (stringId != -1)
		return SearchButtonInstance(lwf->GetStringId(instanceName), recursive);

	if (!m_attachedMovies.empty() && recursive) {
		AttachedMovieList::const_iterator it(m_attachedMovieList.begin()),
			itend(m_attachedMovieList.end());
		for (; it != itend; ++it) {
			if (it->second) {
				Button *button =
					it->second->SearchButtonInstance(instanceName, recursive);
				if (button)
					return button;
			}
		}
	}

	if (!m_attachedLWFs.empty()) {
		AttachedLWFList::const_iterator
			it(m_attachedLWFList.begin()), itend(m_attachedLWFList.end());
		for (; it != itend; ++it) {
			if (it->second) {
				LWF *child = it->second->child.get();
				Button *button = child->rootMovie->SearchButtonInstance(
					instanceName, recursive);
				if (button)
					return button;
			}
		}
	}

	return 0;
}
Exemple #3
0
void Movie::Destroy()
{
	for (int dlDepth = 0; dlDepth < data->depths; ++dlDepth) {
		Object *obj = m_displayList[dlDepth].get();
		if (obj)
			obj->Destroy();
	}

	if (!m_attachedMovies.empty()) {
		AttachedMovies::iterator
			it(m_attachedMovies.begin()), itend(m_attachedMovies.end());
		for (; it != itend; ++it)
			it->second->Destroy();
		m_attachedMovies.clear();
		m_attachedMovieList.clear();
		m_detachedMovies.clear();
	}

	if (!m_attachedLWFs.empty()) {
		AttachedLWFs::iterator
			it(m_attachedLWFs.begin()), itend(m_attachedLWFs.end());
		for (; it != itend; ++it) {
			if (it->second->child->detachHandler) {
				if (it->second->child->detachHandler(it->second->child.get()))
					it->second->child.get()->Destroy();
			} else {
				it->second->child.get()->Destroy();
			}
		}
		m_attachedLWFs.clear();
		m_attachedLWFList.clear();
		m_detachedLWFs.clear();
	}

#if defined(LWF_USE_LUA)
	if (m_isRoot && !m_rootUnloadFunc.empty())
		lwf->CallFunctionLua(m_rootUnloadFunc, this);
	if (!m_unloadFunc.empty())
		lwf->CallFunctionLua(m_unloadFunc, this);
#endif
	PlayAnimation(ClipEvent::UNLOAD);

	if (!m_handler.Empty())
		m_handler.Call(METype::UNLOAD, this);

#if defined(LWF_USE_LUA)
	lwf->DestroyMovieLua(this);
#endif

	m_displayList.clear();
	m_property.reset();

	IObject::Destroy();
}
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_erase_burst()
{
   //value_cont_type values;
   const std::size_t MaxValues = 200;
   value_cont_type values(MaxValues);
   for(std::size_t i = 0; i != MaxValues; ++i){
      (&values[i])->value_ = i;
   }

   typedef typename ContainerDefiner::template container
      <>::type  assoc_type;
   typedef typename assoc_type::iterator iterator;

   {  //Ordered insertion + erasure
      assoc_type testset (values.begin(), values.begin() + values.size());
      TEST_INTRUSIVE_SEQUENCE_EXPECTED(testset, testset.begin());
      testset.check();
      iterator it(testset.begin()), itend(testset.end());
      for(std::size_t i = 0; it != itend; ++i){
         BOOST_TEST(&*it == &values[i]);
         it = testset.erase(it);
         testset.check();
      }
      BOOST_TEST(testset.empty());
   }

   {  //Now random insertions + erasure
      assoc_type testset;
      typedef typename value_cont_type::iterator vec_iterator;
      boost::container::vector<vec_iterator> it_vector;
      //Random insertion
      for(vec_iterator it(values.begin()), itend(values.end())
         ; it != itend
         ; ++it){
         it_vector.push_back(it);
      }
      for(std::size_t i = 0; i != MaxValues; ++i){
         testset.insert(*it_vector[i]);
         testset.check();
      }
      TEST_INTRUSIVE_SEQUENCE_EXPECTED(testset, testset.begin());
      //Random erasure
      std::random_shuffle(it_vector.begin(), it_vector.end());
      for(std::size_t i = 0; i != MaxValues; ++i){
         testset.erase(testset.iterator_to(*it_vector[i]));
         testset.check();
      }
      BOOST_TEST(testset.empty());
   }
}
  Array1D<SampledMapping<2> >
  evaluate(const LDomainJLBasis& basis,
 	   const InfiniteVector<double,Index>& coeffs,
 	   const int N)
  {
    // first prepare a plot of the zero function
    FixedArray1D<Array1D<double>,2> values;
    values[0].resize(N+1);
    values[1].resize(N+1);
    for (int i = 0; i <= N; i++) {
      values[0][i] = 0.;
      values[1][i] = 0.;
    }
    Array1D<SampledMapping<2> > result(3);
    result[0] = SampledMapping<2>(Point<2>(-1, 0), Point<2>(0,1), values);
    result[1] = SampledMapping<2>(Point<2>(-1,-1), Point<2>(0,0), values);
    result[2] = SampledMapping<2>(Point<2>( 0,-1), Point<2>(1,0), values);
          
    // add all plots of the single functions
    for (InfiniteVector<double,Index>::const_iterator it(coeffs.begin()),
 	   itend(coeffs.end()); it != itend; ++it) {
      Array1D<SampledMapping<2> > temp(evaluate(basis, it.index(), N));
      result[0].add(*it, temp[0]);
      result[1].add(*it, temp[1]);
      result[2].add(*it, temp[2]);
    }
    
    return result;
  }
void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
{
  NetworkConstantActionPtr action = NULL;
  ActionListPtr actionSet = getRunningActionSet();
  for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
     ; it != itend ; it=itNext) {
    ++itNext;
	action = static_cast<NetworkConstantActionPtr>(&*it);
    if (action->m_latency > 0) {
      if (action->m_latency > delta) {
        double_update(&(action->m_latency), delta, sg_surf_precision);
      } else {
        action->m_latency = 0.0;
      }
    }
    action->updateRemains(action->getCost() * delta / action->m_latInit);
    if (action->getMaxDuration() != NO_MAX_DURATION)
      action->updateMaxDuration(delta);

    if (action->getRemainsNoUpdate() <= 0) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    } else if ((action->getMaxDuration() != NO_MAX_DURATION)
               && (action->getMaxDuration() <= 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    }
  }
}
double WorkstationL07Model::shareResources(double /*now*/)
{
  WorkstationL07ActionPtr action;

  ActionListPtr running_actions = getRunningActionSet();
  double min = this->shareResourcesMaxMin(running_actions,
                                              ptask_maxmin_system,
                                              bottleneck_solve);

  for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end())
	 ; it != itend ; ++it) {
	action = static_cast<WorkstationL07ActionPtr>(&*it);
    if (action->m_latency > 0) {
      if (min < 0) {
        min = action->m_latency;
        XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
               action->getStartTime(), min);
      } else if (action->m_latency < min) {
        min = action->m_latency;
        XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
               action->getStartTime(), min);
      }
    }
  }

  XBT_DEBUG("min value : %f", min);

  return min;
}
Exemple #8
0
void Movie::DetachAllLWFs()
{
	AttachedLWFs::const_iterator
		it(m_attachedLWFs.begin()), itend(m_attachedLWFs.end());
	for (; it != itend; ++it)
		m_detachedLWFs[it->second->child->attachName] = true;
}
    void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
    {
      NetworkConstantAction *action = nullptr;
      ActionList *actionSet = getRunningActionSet();
      for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
          ; it != itend ; it=itNext) {
        ++itNext;
        action = static_cast<NetworkConstantAction*>(&*it);
        if (action->latency_ > 0) {
          if (action->latency_ > delta) {
            double_update(&(action->latency_), delta, sg_surf_precision);
          } else {
            action->latency_ = 0.0;
          }
        }
        action->updateRemains(action->getCost() * delta / action->initialLatency_);
        if (action->getMaxDuration() != NO_MAX_DURATION)
          action->updateMaxDuration(delta);

        if (action->getRemainsNoUpdate() <= 0) {
          action->finish();
          action->setState(Action::State::done);
        } else if ((action->getMaxDuration() != NO_MAX_DURATION)
            && (action->getMaxDuration() <= 0)) {
          action->finish();
          action->setState(Action::State::done);
        }
      }
    }
 void Vector<C>::scale(const C s)
 {
   assert(size_ > 0);
   
   iterator it(begin()), itend(end());
   while(it != itend)
     *it++ *= s;
 }
Exemple #11
0
void StorageN11Model::updateActionsState(double /*now*/, double delta)
{
  StorageAction *action = nullptr;

  ActionList *actionSet = getRunningActionSet();
  for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
      ; it != itend ; it=itNext) {
    ++itNext;
    action = static_cast<StorageAction*>(&*it);

    if(action->m_type == WRITE){
      // Update the disk usage
      // Update the file size
      // For each action of type write
      double current_progress =
          delta * lmm_variable_getvalue(action->getVariable());
      long int incr = current_progress;

      XBT_DEBUG("%s:\n\t progress =  %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
          action->p_file->name,
          action->progress,  current_progress, incr,
          lrint(action->progress + current_progress),
          lrint(action->progress)+ incr);

      /* take care of rounding error accumulation */
      if (lrint(action->progress + current_progress) > lrint(action->progress)+ incr)
        incr++;

      action->progress +=current_progress;

      action->p_storage->usedSize_ += incr; // disk usage
      action->p_file->current_position+= incr; // current_position
      //  which becomes the new file size
      action->p_file->size = action->p_file->current_position ;

      sg_size_t *psize = xbt_new(sg_size_t,1);
      *psize = action->p_file->size;
      xbt_dict_t content_dict = action->p_storage->content_;
      xbt_dict_set(content_dict, action->p_file->name, psize, nullptr);
    }

    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);

    if (action->getMaxDuration() > NO_MAX_DURATION)
      action->updateMaxDuration(delta);

    if(action->getRemainsNoUpdate() > 0 && lmm_get_variable_weight(action->getVariable()) > 0 &&
        action->p_storage->usedSize_ == action->p_storage->size_) {
      action->finish();
      action->setState(Action::State::failed);
    } else if (((action->getRemainsNoUpdate() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
               ((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
      action->finish();
      action->setState(Action::State::done);
    }
  }
  return;
}
  void Vector<C>::compress(const double eta)
  {
    for (iterator it(begin()), itend(end());
	 it != itend; ++it)
      {
	if (fabs(*it) < eta)
	  *it = C(0);
      }
  }
void test_generic_assoc<ValueTraits, ContainerDefiner>::test_insert_before
(value_cont_type& values, detail::true_type)
{
   typedef typename ContainerDefiner::template container
      <>::type assoc_type;
   {
      assoc_type testset;
      typedef typename value_cont_type::iterator vec_iterator;
      for(vec_iterator it(values.begin()), itend(values.end())
         ; it != itend
         ; ++it){
         testset.push_back(*it);
      }
      BOOST_TEST(testset.size() == values.size());
      TEST_INTRUSIVE_SEQUENCE_EXPECTED(values, testset.begin());
   }
   {
      assoc_type testset;
      typedef typename value_cont_type::iterator vec_iterator;

      for(vec_iterator it(--values.end()); true; --it){
         testset.push_front(*it);
       if(it == values.begin()){
            break;
       }
      }
      BOOST_TEST(testset.size() == values.size());
      TEST_INTRUSIVE_SEQUENCE_EXPECTED(values, testset.begin());
   }
   {
      assoc_type testset;
      typedef typename value_cont_type::iterator vec_iterator;
      typename assoc_type::iterator it_pos =
         testset.insert_before(testset.end(), *values.rbegin());
      testset.insert_before(testset.begin(), *values.begin());
      for(vec_iterator it(++values.begin()), itend(--values.end())
         ; it != itend
         ; ++it){
         testset.insert_before(it_pos, *it);
      }
      BOOST_TEST(testset.size() == values.size());
      TEST_INTRUSIVE_SEQUENCE_EXPECTED(values, testset.begin());
   }
}
Exemple #14
0
 void deallocate_nodes(multiallocation_chain chain)
 {
    typedef typename multiallocation_chain::iterator iterator;
    iterator it(chain.begin()), itend(chain.end());
    while(it != itend){
       void *pElem = &*it;
       ++it;
       priv_dealloc_node(pElem);
    }
 }
  void Vector<C>::add(const C2 s, const Vector<C2>& v)
  {
    assert(size_ > 0);
    assert(size_ == v.size());

    iterator it(begin()), itend(end());
    typename Vector<C2>::const_iterator itv(v.begin());
    while (it != itend)
      *it++ += s * *itv++;
  }
Exemple #16
0
Movie *Movie::SearchMovieInstance(string instanceName, bool recursive) const
{
	int stringId = lwf->GetStringId(instanceName);
	if (stringId != -1)
		return SearchMovieInstance(lwf->GetStringId(instanceName), recursive);

	if (!m_attachedMovies.empty()) {
		AttachedMovieList::const_iterator it(m_attachedMovieList.begin()),
			itend(m_attachedMovieList.end());
		for (; it != itend; ++it) {
			if (it->second) {
				if (it->second->attachName == instanceName) {
					return it->second.get();
				} else if (recursive) {
					Movie *movie = it->second->SearchMovieInstance(
						instanceName, recursive);
					if (movie)
						return movie;
				}
			}
		}
	}

	if (!m_attachedLWFs.empty()) {
		AttachedLWFList::const_iterator
			it(m_attachedLWFList.begin()), itend(m_attachedLWFList.end());
		for (; it != itend; ++it) {
			if (it->second) {
				LWF *child = it->second->child.get();
				if (child->attachName == instanceName) {
					return child->rootMovie.get();
				} else if (recursive) {
					Movie *movie = child->rootMovie->SearchMovieInstance(
						instanceName, recursive);
					if (movie)
						return movie;
				}
			}
		}
	}

	return 0;
}
Exemple #17
0
    void validate_import(){
	for(int i=0; i<num_cells_x; i++) for(int j=0; j<num_cells_y; j++) for(int k=0; k<num_cells_z; k++){
		    std::vector<particle>::iterator it(cell(i,j,k).begin()), itend(cell(i,j,k).end());
		    std::cout<<"~~~~~~~~in cell "<<i<<","<<j<<","<<k<<"~~~~~~~~\n";
		    for(; it!=itend; it++){
			std::cout<<" particle "<<(*it).index; fflush(stdout);
			std::cout<<" has position "<<(*it).r<<"\n";
		    }
		}
    }
  void Vector<C>::subtract(const Vector<C2>& v)
  {
    assert(size_ > 0);
    assert(size_ == v.size());

    iterator it(begin()), itend(end());
    typename Vector<C2>::const_iterator itv(v.begin());
    while (it != itend)
      *it++ -= *itv++;
  }
Exemple #19
0
void Movie::DispatchEvent(string eventName)
{
	if (m_handler.Call(eventName, this))
		return;

	scoped_ptr<MovieEventHandlerList> list(
		new MovieEventHandlerList(m_eventHandlers[eventName]));
	MovieEventHandlerList::iterator it(list->begin()), itend(list->end());
	for (; it != itend; ++it)
		it->second(this);
}
void test_container( Container & c )
{
   typedef typename Container::const_iterator   const_iterator;
   typedef typename Container::iterator         iterator;
   typedef typename Container::size_type        size_type;

   {test_container_typedefs<Container> dummy;  (void)dummy;}
   const size_type num_elem = c.size();
   BOOST_TEST( c.empty() == (num_elem == 0) );
   {
      iterator it(c.begin()), itend(c.end());
      size_type i;
      for(i = 0; i < num_elem; ++i){
         ++it;
      }
      BOOST_TEST( it == itend );
      BOOST_TEST( c.size() == i );
   }

   //Check iterator conversion
   BOOST_TEST(const_iterator(c.begin()) == c.cbegin() );
   {
      const_iterator it(c.cbegin()), itend(c.cend());
      size_type i;
      for(i = 0; i < num_elem; ++i){
         ++it;
      }
      BOOST_TEST( it == itend );
      BOOST_TEST( c.size() == i );
   }
   static_cast<const Container&>(c).check();
   //Very basic test for comparisons
   {
      BOOST_TEST(c == c);
      BOOST_TEST(!(c != c));
      BOOST_TEST(!(c < c));
      BOOST_TEST(c <= c);
      BOOST_TEST(!(c > c));
      BOOST_TEST(c >= c);
   }
}
  void
  JLBasis::reconstruct(const InfiniteVector<double, Index>& c,
		       const int j,
		       InfiniteVector<double, Index>& v) const {
    v.clear();
    for (InfiniteVector<double, Index>::const_iterator it(c.begin()), itend(c.end());
	 it != itend; ++it) {
      InfiniteVector<double, Index> help;
      reconstruct_1(it.index(), j, help);
      v.add(*it, help);
    }
  }
Exemple #22
0
void Movie::Inspect(
	Inspector inspector, int hierarchy, int inspectDepth, int rOffset)
{
	if (m_property->hasRenderingOffset) {
		lwf->RenderOffset();
		rOffset = m_property->renderingOffset;
	}
	if (rOffset == INT_MIN)
		lwf->ClearRenderOffset();

	inspector(this, hierarchy, inspectDepth, rOffset);

	++hierarchy;

	int d;
	for (d = 0; d < data->depths; ++d) {
		Object *obj = m_displayList[d].get();
		if (obj)
			obj->Inspect(inspector, hierarchy, d, rOffset);
	}

	if (!m_attachedMovies.empty()) {
		AttachedMovieList::iterator
			it(m_attachedMovieList.begin()), itend(m_attachedMovieList.end());
		for (; it != itend; ++it)
			if (it->second)
				it->second->Inspect(inspector, hierarchy, d++, rOffset);
	}

	if (!m_attachedLWFs.empty()) {
		AttachedLWFList::iterator
			it(m_attachedLWFList.begin()), itend(m_attachedLWFList.end());
		for (; it != itend; ++it) {
			if (it->second) {
				lwf->RenderObject(it->second->child->Inspect(
					inspector, hierarchy, d++, rOffset));
			}
		}
	}
}
  void Vector<C>::sadd(const C s, const Vector<C2>& v)
  {
    assert(size_ > 0);
    assert(size_ == v.size());

    iterator it(begin()), itend(end());
    typename Vector<C2>::const_iterator itv(v.begin());
    while(it != itend)
      {
	*it = s*(*it) + *itv++;
	++it;
      }
  }
double NetworkConstantModel::shareResources(double /*now*/)
{
  NetworkConstantActionPtr action = NULL;
  double min = -1.0;

  ActionListPtr actionSet = getRunningActionSet();
  for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
	 ; it != itend ; ++it) {
	action = static_cast<NetworkConstantActionPtr>(&*it);
        if (action->m_latency > 0 && (min < 0 || action->m_latency < min))
            min = action->m_latency;
  }

  return min;
}
    double NetworkConstantModel::next_occuring_event(double /*now*/)
    {
      NetworkConstantAction *action = nullptr;
      double min = -1.0;

      ActionList *actionSet = getRunningActionSet();
      for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
          ; it != itend ; ++it) {
        action = static_cast<NetworkConstantAction*>(&*it);
        if (action->latency_ > 0 && (min < 0 || action->latency_ < min))
          min = action->latency_;
      }

      return min;
    }
Exemple #26
0
void Movie::ReorderAttachedLWFList(
	bool reorder, int index, shared_ptr<LWFContainer> lwfContainer)
{
	m_attachedLWFList[index] = lwfContainer;
	if (reorder) {
		AttachedLWFList list(m_attachedLWFList);
		m_attachedLWFList.clear();
		int i = 0;
		AttachedLWFList::iterator it(list.begin()), itend(list.end());
		for (; it != itend; ++it) {
			it->second->child->depth = i;
			m_attachedLWFList[i] = it->second;
			++i;
		}
	}
}
Exemple #27
0
void Movie::ReorderAttachedMovieList(
	bool reorder, int index, shared_ptr<Movie> movie)
{
	m_attachedMovieList[index] = movie;
	if (reorder) {
		AttachedMovieList list(m_attachedMovieList);
		m_attachedMovieList.clear();
		int i = 0;
		AttachedMovieList::iterator it(list.begin()), itend(list.end());
		for (; it != itend; ++it) {
			it->second->depth = i;
			m_attachedMovieList[i] = it->second;
			++i;
		}
	}
}
  const C Vector<C>::inner_product (const Vector<C2>& v) const
  {
    assert(size_ == v.size());

    if (this == reinterpret_cast<const Vector<C>*>(&v))
      return l2_norm_sqr(*this);

    C r(0);
    
    const_iterator it(begin()), itend(end());
    typename Vector<C2>::const_iterator itv(v.begin());
    while(it != itend)
      r += *it++ * *itv++;

    return r;
  }
Exemple #29
0
void MovieEventHandlers::Add(int eventId, const MovieEventHandlerDictionary &h)
{
	MovieEventHandlerDictionary::const_iterator it(h.begin()), itend(h.end());
	PrepareTable();
	table_t::const_iterator titend(table.end());
	for (; it != itend; ++it) {
		table_t::const_iterator tit(table.begin());
		for (; tit != titend; ++tit) {
			if (it->first == tit->first) {
				m_handlers[tit->second].push_back(
					make_pair(eventId, it->second));
			}
		}
	}
	if (m_empty)
		UpdateEmpty();
}
  double
  Vector<C>::wrmsqr_norm(const double atol, const double rtol,
			 const Vector<C>& v, const Vector<C>& w) const
  {
    assert(size() == w.size());

    double result = 0;
    
    for (const_iterator it(begin()), itv (v.begin()), itw(w.begin()), itend(end());
	 it != itend; ++it, ++itv, ++itw)
      {
	const double help = *it / (atol + rtol * std::max(*itv, *itw));
	result += help * help;
      }

    return result == 0 ? 0 : sqrt(result/size());
  }