Esempio n. 1
0
  bool CachedResults<T>::GetCachedResult(T& retResult, const std::vector<const TaggedObject*>& dependents,
                                         const std::vector<Number>& scalar_dependents) const
  {
#ifdef IP_DEBUG_CACHE
    DBG_START_METH("CachedResults<T>::GetCachedResult", dbg_verbosity);
#endif

    if (!cached_results_)
      return false;

    CleanupInvalidatedResults();

    bool retValue = false;
    typename std::list< DependentResult<T>* >::const_iterator iter;
    for (iter = cached_results_->begin(); iter != cached_results_->end(); iter++) {
      if ((*iter)->DependentsIdentical(dependents, scalar_dependents)) {
        retResult = (*iter)->GetResult();
        retValue = true;
        break;
      }
    }

#ifdef IP_DEBUG_CACHE
    DBG_EXEC(2, DebugPrintCachedResults());
#endif

    return retValue;
  }
Esempio n. 2
0
  void CachedResults<T>::AddCachedResult(const T& result,
                                         const std::vector<const TaggedObject*>& dependents,
                                         const std::vector<Number>& scalar_dependents)
  {
#ifdef IP_DEBUG_CACHE
    DBG_START_METH("CachedResults<T>::AddCachedResult", dbg_verbosity);
#endif

    CleanupInvalidatedResults();

    // insert the new one here
    DependentResult<T>* newResult = new DependentResult<T>(result, dependents, scalar_dependents);
    if (!cached_results_) {
      cached_results_ = new std::list<DependentResult<T>*>;
    }
    cached_results_->push_front(newResult);

    // keep the list small enough
    if (max_cache_size_ >= 0) { // if negative, allow infinite cache
      // non-negative - limit size of list to max_cache_size
      DBG_ASSERT((Int)cached_results_->size()<=max_cache_size_+1);
      if ((Int)cached_results_->size() > max_cache_size_) {
        delete cached_results_->back();
        cached_results_->pop_back();
      }
    }

#ifdef IP_DEBUG_CACHE
    DBG_EXEC(2, DebugPrintCachedResults());
#endif

  }
Esempio n. 3
0
 void FileJournal::PrintfImpl(const char* pformat, va_list ap)
 {
   DBG_START_METH("Journal::Printf", 0);
   if (file_) {
     vfprintf(file_, pformat, ap);
     DBG_EXEC(0, fflush(file_));
   }
 }
Esempio n. 4
0
 void FileJournal::PrintImpl(const char* str)
 {
   DBG_START_METH("Journal::Print", 0);
   if (file_) {
     fprintf(file_, str, 0); // dummy argument avoids gcc warning
     DBG_EXEC(0, fflush(file_));
   }
 }
Esempio n. 5
0
 void StreamJournal::PrintImpl(EJournalCategory category, EJournalLevel level,
                               const char* str)
 {
   DBG_START_METH("StreamJournal::PrintImpl", 0);
   if (os_) {
     *os_ << str;
     DBG_EXEC(0, *os_ << std::flush);
   }
 }
Esempio n. 6
0
 void FileJournal::PrintfImpl(EJournalCategory category, EJournalLevel level,
                              const char* pformat, va_list ap)
 {
   DBG_START_METH("Journal::Printf", 0);
   if (file_) {
     vfprintf(file_, pformat, ap);
     DBG_EXEC(0, fflush(file_));
   }
 }
Esempio n. 7
0
 void FileJournal::PrintImpl(EJournalCategory category, EJournalLevel level,
                             const char* str)
 {
   DBG_START_METH("Journal::Print", 0);
   if (file_) {
     fprintf(file_, "%s", str);
     DBG_EXEC(0, fflush(file_));
   }
 }
Esempio n. 8
0
 void StreamJournal::PrintfImpl(EJournalCategory category, EJournalLevel level,
                                const char* pformat, va_list ap)
 {
   DBG_START_METH("StreamJournal::PrintfImpl", 0);
   if (os_) {
     vsprintf(buffer_, pformat, ap);
     *os_ << buffer_;
     DBG_EXEC(0, *os_ << std::flush);
   }
 }