Esempio n. 1
0
int SevenZipPlugin::QueryArchives(
		const unsigned char* pBuffer, 
		DWORD dwBufferSize, 
		const TCHAR* lpFileName, 
		Array<ArchiveQueryResult*>& result
		)
{
	ObjectArray<FormatPosition*> formats;

	FindFormats(pBuffer, dwBufferSize, lpFileName, formats);

	formats.sort((void*)SortFormats, NULL);

	for (unsigned int i = 0; i < formats.count(); i++)
	{
		ArchiveQueryResult* pResult = new ArchiveQueryResult;

		pResult->uidPlugin = m_uid;
		pResult->uidFormat = *formats[i]->puid;

		result.add(pResult);
	}

	return formats.count(); //badbad, return added only!!!
}
Esempio n. 2
0
UGenArray::UGenArray(ObjectArray<UGen> const& array) throw()
:	internal((array.length() <= 0) ? 0 : new Internal(array.length()))
{
	if(internal != 0)
	{
		for(int i = 0; i < internal->size(); i++)
		{
			internal->getArray()[i] = array[i];
		}
	}
}
Esempio n. 3
0
	int Run()
	{
		return Info.Message(
				Info.ModuleNumber,
				m_dwFlags,
				NULL,
				m_items.data(),
				m_items.count(),
				m_buttons
				);
	}
Esempio n. 4
0
 // Assume ObjectArray is a vector!
 void promoted_push(Object* obj) {
   if(promoted_insert == promoted_current) {
     size_t i = promoted_insert - promoted_->begin(),
            j = promoted_current - promoted_->begin();
     promoted_->push_back(obj);
     promoted_current = promoted_->begin() + j;
     promoted_insert = promoted_->begin() + i;
   } else {
     *promoted_insert++ = obj;
   }
 }
Esempio n. 5
0
//------------------------------------------------------------------------------
void RunSimulator::SetPropagationProperties(PropagationStateManager *psm)
{
   ObjectArray pObjects;
   psm->GetStateObjects(pObjects, Gmat::UNKNOWN_OBJECT);

   for (ObjectArray::iterator p = pObjects.begin(); p != pObjects.end(); ++p)
   {
      if ((*p)->IsOfType(Gmat::SPACEOBJECT))
      {
         if (includeSTMPropagation)
            psm->SetProperty("STM", *p);
      }
   }
}
Esempio n. 6
0
//------------------------------------------------------------------------------
bool StateManager::GetStateObjects(ObjectArray& pObjects, Gmat::ObjectType type)
{
   bool retval = false;
   
   if (type == Gmat::UNKNOWN_OBJECT)
   {
      for (ObjectArray::iterator i = objects.begin(); i != objects.end(); ++i)
      {
         if (find(pObjects.begin(), pObjects.end(), (*i)) == pObjects.end())
         {
            pObjects.push_back(*i);
            retval = true;
         }
      }
   }
   else
   {
      for (ObjectArray::iterator i = objects.begin(); i != objects.end(); ++i)
      {
         if ((*i)->IsOfType(type))
         {
            if (find(pObjects.begin(), pObjects.end(), (*i)) == pObjects.end())
            {
               pObjects.push_back(*i);
               retval = true;
            }
         }
      }
   }
   
   return retval;
}
Esempio n. 7
0
//------------------------------------------------------------------------------
Integer StateManager::GetCount(Gmat::StateElementId elementType)
{
   ObjectArray pObjects;
 
   GetStateObjects(pObjects, Gmat::UNKNOWN_OBJECT);
   Integer count = pObjects.size();

   #ifdef DEBUG_STATE_ACCESS
      MessageInterface::ShowMessage(
            "StateManager::GetCount found %d objects supporting type %d\n",
            count, elementType);
   #endif
      
   return count;
}
Esempio n. 8
0
  void ObjectMemory::print_references(STATE, Object* obj) {
    ObjectArray ary;

    find_referers(obj, ary);

    int count = 0;

    std::cout << ary.size() << " total references:\n";
    for(ObjectArray::iterator i = ary.begin();
        i != ary.end();
        ++i) {
      std::cout << "  " << (*i)->to_s(state, true)->c_str(state) << "\n";

      if(++count == 100) break;
    }
  }
Esempio n. 9
0
  void ObjectMemory::find_referers(Object* target, ObjectArray& result) {
    ObjectMemory::GCInhibit inhibitor(this);

    ObjectWalker walker(root_state_->om);
    GCData gc_data(root_state_);

    // Seed it with the root objects.
    walker.seed(gc_data);

    Object* obj = walker.next();

    RefererFinder rf(this, target);

    while(obj) {
      rf.reset();

      rf.scan_object(obj);

      if(rf.found_p()) {
        result.push_back(obj);
      }

      obj = walker.next();
    }
  }
Esempio n. 10
0
    /**
     * Adds a weak reference to the specified object.
     *
     * A weak reference provides a way to hold a reference to an object without
     * that reference being sufficient to keep the object alive. If no other
     * reference to the weak-referenced object exists, it can be collected by
     * the garbage collector, with the weak-reference subsequently returning
     * null.
     */
    void add_weak_ref(Object* obj) {
      if(!weak_refs_) {
        weak_refs_ = new ObjectArray;
      }

      weak_refs_->push_back(obj);
    }
Esempio n. 11
0
TextArray::TextArray (ObjectArray<RowType> const& other) throw()
:	Base (other.size())
{
    const int rows = this->size();
    
    for (int row = 0; row < rows; ++row)
        this->put (row, Text (other[row]));
}
Esempio n. 12
0
//------------------------------------------------------------------------------
void EstimationStateManager::RestoreObjects(ObjectArray *fromBuffer)
{
   #ifdef DEBUG_CLONING
      MessageInterface::ShowMessage("EstimationStateManager::RestoreObjects(%p)"
            " called\n", fromBuffer);
      MessageInterface::ShowMessage("   %d objects and %d clones\n",
            objects.size(), estimationObjectClones.size());
   #endif

   ObjectArray *restoreBuffer = fromBuffer;
   if (fromBuffer == NULL)
   {
      restoreBuffer = &estimationObjectClones;
      MessageInterface::ShowMessage("Using internal buffer\n");
   }

   if (restoreBuffer->size() != objects.size())
   {
      std::stringstream errmsg;
      errmsg << "EstimationStateManager::RestoreObjects(): "
                "Clone size mismatch; there are " << objects.size()
             << " objects and " << restoreBuffer->size() << " clones.";
      throw EstimatorException(errmsg.str());
   }

   for (UnsignedInt i = 0; i < restoreBuffer->size(); ++i)
   {
      #ifdef DEBUG_CLONING
         MessageInterface::ShowMessage("Setting object %s from clone named "
               "%s\n", objects[i]->GetName().c_str(),
               (*restoreBuffer)[i]->GetName().c_str());
      #endif
      if (objects[i]->IsOfType(Gmat::SPACECRAFT))
         ((Spacecraft*)(objects[i]))->operator=(*((Spacecraft*)((*restoreBuffer)[i])));
      else
         *(objects[i]) = *((*restoreBuffer)[i]);
      #ifdef DEBUG_CLONING
         MessageInterface::ShowMessage("Object data:\n%s",
               objects[i]->GetGeneratingString(Gmat::SHOW_SCRIPT, "   ").c_str());
      #endif
   }
   #ifdef DEBUG_CLONING
      MessageInterface::ShowMessage("EstimationStateManager::RestoreObjects() "
            "finished\n");
   #endif
}
Esempio n. 13
0
	void Add(const TCHAR *lpStr)
	{
		size_t length = _tcslen(lpStr);
		TCHAR *lpCopy = new TCHAR[length+1];

		_tcscpy(lpCopy, lpStr);

		m_items.add(lpCopy);
	}
Esempio n. 14
0
bool SphereObjectFactory::create(
    const char*            name,
    const ParamArray&      params,
    const SearchPaths&     search_paths,
    const bool             omit_loading_assets,
    ObjectArray&           objects) const
{
    objects.push_back(create(name, params).release());
    return true;
}
void dumpTree(std::ostream& result, Node node, std::string indent)
{
    while (node) {
        result << indent << node << '\n';
        Element element = interface_cast<Element>(node);
        if (element.getNodeType() == Node::ELEMENT_NODE) {
            ObjectArray<Attr> attrArray = element.getAttributes();
            assert(attrArray);
            for (unsigned int i = 0; i < attrArray.getLength(); ++i) {
                Attr attr = attrArray.getElement(i);
                assert(attr);
                result << indent << "  " << attr.getName() << "=\"" << attr.getValue() << "\"\n";
            }
        }
        if (node.hasChildNodes())
            dumpTree(result, node.getFirstChild(), indent + ((node.getNodeType() == Node::DOCUMENT_NODE) ? "| " : "  "));
        node = node.getNextSibling();
    }
}
Esempio n. 16
0
//------------------------------------------------------------------------------
Real EstimationRootFinder::Locate(ObjectArray &whichOnes)
{
   #ifdef DEBUG_ROOT_SEARCH
      MessageInterface::ShowMessage("EstimationRootFinder::Locate called with %d "
            "events\n", whichOnes.size());
   #endif
   Real rootEpoch = -1.0;

   events = (std::vector<Event*>*)(&whichOnes);

   for (UnsignedInt i = 0; i < whichOnes.size(); ++i)
   {
      Real foundEpoch = FindRoot(i);
      if (foundEpoch > 0.0)
      {
         rootEpoch = (rootEpoch == -1.0 ? foundEpoch :
                      (rootEpoch > foundEpoch ? foundEpoch : rootEpoch));
      }
   }

   return rootEpoch;
}
Esempio n. 17
0
//-----------------------------------------------------------------------------
Real EventManager::FindRoot(Integer whichOne)
{
   #ifdef DEBUG_EVENTMAN_FINDROOT
      MessageInterface::ShowMessage("EventManager::FindRoot looking for "
            "root %d out of %d known events\n", whichOne, events.size());
   #endif
   Real rootTime = -1.0;

   ObjectArray eventList;
   eventList.clear();

   // For now, just find one root in this call
   if ((whichOne >= 0) && (whichOne < (Integer)events.size()))
   {
      #ifdef DEBUG_EVENTMAN_FINDROOT
         MessageInterface::ShowMessage("   Placing %s on the stack\n",
               events[whichOne]->GetName().c_str());
      #endif

      eventList.push_back(events[whichOne]);
      #ifdef DEBUG_EVENTMAN_FINDROOT
         MessageInterface::ShowMessage("   Calling RootFinder to check the "
               "current event list\n");
      #endif
      rootTime = locater.Locate(eventList);

      ((Event*)events[whichOne])->Evaluate();
      // Now calculate the next time step estimate based on propagated states
      ((Event*)events[whichOne])->EstimateTimestep();

      #ifdef DEBUG_EVENTMAN_FINDROOT
         MessageInterface::ShowMessage("   Evaluated event function; status is "
               "now %d\n", ((Event*)events[whichOne])->CheckStatus());
      #endif
   }

   return rootTime;
}
Esempio n. 18
0
bool FiniteBurn::DepletesMass()
{
    bool retval = false;

    ObjectArray thrusterArray = spacecraft->GetRefObjectArray(Gmat::THRUSTER);

    // Check each the thruster
    for (ObjectArray::iterator th = thrusterArray.begin();
            th != thrusterArray.end(); ++th)
    {
        if ((*th)->GetBooleanParameter("DecrementMass"))
        {
            retval = true;
#ifdef DEBUG_MASS_FLOW
            MessageInterface::ShowMessage("Thruster %s decrements mass\n",
                                          (*th)->GetName().c_str());
#endif
            // Save the mass depleting thruster pointer(s) for later access?
        }
    }

    return retval;
}
Esempio n. 19
0
//------------------------------------------------------------------------------
ObjectArray& Formation::GetRefObjectArray(const Gmat::ObjectType type)
{
   static ObjectArray oa;
   oa.clear();
   if ((type == Gmat::SPACECRAFT) || (type == Gmat::FORMATION))
   {
      for (std::vector<SpaceObject *>::iterator i = components.begin();
           i != components.end(); ++i)
         if ((*i)->GetType() == type)
            oa.push_back(*i);
      return oa;
   }

   if (type == Gmat::SPACEOBJECT)
   {
      for (std::vector<SpaceObject *>::iterator i = components.begin();
           i != components.end(); ++i)
         oa.push_back(*i);
      return oa;
   }
      
   return FormationInterface::GetRefObjectArray(type);
}
Esempio n. 20
0
  void ImmixGC::collect(GCData& data) {
    Object* tmp;

    gc_.clear_lines();

    int via_handles_ = 0;
    int via_roots = 0;
    int via_stack = 0;
    int callframes = 0;

    for(Roots::Iterator i(data.roots()); i.more(); i.advance()) {
      tmp = i->get();
      if(tmp->reference_p()) saw_object(tmp);
      via_roots++;
    }

    if(data.threads()) {
      for(std::list<ManagedThread*>::iterator i = data.threads()->begin();
          i != data.threads()->end();
          i++) {
        for(Roots::Iterator ri((*i)->roots()); ri.more(); ri.advance()) {
          ri->set(saw_object(ri->get()));
        }
      }
    }

    for(capi::Handles::Iterator i(*data.handles()); i.more(); i.advance()) {
      if(i->in_use_p() && !i->weak_p()) {
        saw_object(i->object());
        via_handles_++;
      }
    }

    for(capi::Handles::Iterator i(*data.cached_handles()); i.more(); i.advance()) {
      if(i->in_use_p() && !i->weak_p()) {
        saw_object(i->object());
        via_handles_++;
      }
    }

    std::list<capi::Handle**>* gh = data.global_handle_locations();

    if(gh) {
      for(std::list<capi::Handle**>::iterator i = gh->begin();
          i != gh->end();
          i++) {
        capi::Handle** loc = *i;
        if(capi::Handle* hdl = *loc) {
          if(!CAPI_REFERENCE_P(hdl)) continue;
          if(hdl->valid_p()) {
            Object* obj = hdl->object();
            if(obj && obj->reference_p()) {
              saw_object(obj);
              via_handles_++;
            }
          } else {
            std::cerr << "Detected bad handle checking global capi handles\n";
          }
        }
      }
    }

    for(VariableRootBuffers::Iterator i(data.variable_buffers());
        i.more(); i.advance()) {
      Object*** buffer = i->buffer();
      for(int idx = 0; idx < i->size(); idx++) {
        Object** var = buffer[idx];
        Object* tmp = *var;

        via_stack++;
        if(tmp->reference_p() && tmp->young_object_p()) {
          saw_object(tmp);
        }
      }
    }

    // Walk all the call frames
    for(CallFrameLocationList::const_iterator i = data.call_frames().begin();
        i != data.call_frames().end();
        i++) {
      callframes++;
      CallFrame** loc = *i;
      walk_call_frame(*loc);
    }

    gc_.process_mark_stack(allocator_);

    // We've now finished marking the entire object graph.

    check_finalize();

    // Finalize can cause more things to continue to live, so we must
    // check the mark_stack again.
    gc_.process_mark_stack(allocator_);

    // Sweep up the garbage
    gc_.sweep_blocks();

    // This resets the allocator state to sync it up with the BlockAllocator
    // properly.
    allocator_.get_new_block();

    ObjectArray *current_rs = object_memory_->remember_set();

    int cleared = 0;

    for(ObjectArray::iterator oi = current_rs->begin();
        oi != current_rs->end();
        oi++) {
      tmp = *oi;
      // unremember_object throws a NULL in to remove an object
      // so we don't have to compact the set in unremember
      if(tmp) {
        assert(tmp->zone() == MatureObjectZone);
        assert(!tmp->forwarded_p());

        if(!tmp->marked_p(object_memory_->mark())) {
          cleared++;
          *oi = NULL;
        }
      }
    }

    for(std::list<gc::WriteBarrier*>::iterator wbi = object_memory_->aux_barriers().begin();
        wbi != object_memory_->aux_barriers().end();
        wbi++) {
      gc::WriteBarrier* wb = *wbi;
      ObjectArray* rs = wb->remember_set();
      for(ObjectArray::iterator oi = rs->begin();
          oi != rs->end();
          oi++) {
        tmp = *oi;

        if(tmp) {
          assert(tmp->zone() == MatureObjectZone);
          assert(!tmp->forwarded_p());

          if(!tmp->marked_p(object_memory_->mark())) {
            cleared++;
            *oi = NULL;
          }
        }
      }
    }


    // Now, calculate how much space we're still using.
    immix::Chunks& chunks = gc_.block_allocator().chunks();
    immix::AllBlockIterator iter(chunks);

    int live_bytes = 0;
    int total_bytes = 0;

    while(immix::Block* block = iter.next()) {
      total_bytes += immix::cBlockSize;
      live_bytes += block->bytes_from_lines();
    }

    double percentage_live = (double)live_bytes / (double)total_bytes;

    if(object_memory_->state->shared.config.gc_immix_debug) {
      std::cerr << "[GC IMMIX: " << clear_marked_objects() << " marked"
                << ", "
                << via_roots << " roots "
                << via_handles_ << " handles "
                << (int)(percentage_live * 100) << "% live"
                << ", " << live_bytes << "/" << total_bytes
                << "]\n";
    }

    if(percentage_live >= 0.90) {
      if(object_memory_->state->shared.config.gc_immix_debug) {
        std::cerr << "[GC IMMIX: expanding. "
                   << (int)(percentage_live * 100)
                   << "%]\n";
      }
      gc_.block_allocator().add_chunk();
    }

#ifdef IMMIX_DEBUG
    std::cout << "Immix: RS size cleared: " << cleared << "\n";

    immix::Chunks& chunks = gc_.block_allocator().chunks();
    std::cout << "chunks=" << chunks.size() << "\n";

    immix::AllBlockIterator iter(chunks);

    int blocks_seen = 0;
    int total_objects = 0;
    int total_object_bytes = 0;

    while(immix::Block* block = iter.next()) {
      blocks_seen++;
      std::cout << "block " << block << ", holes=" << block->holes() << " "
                << "objects=" << block->objects() << " "
                << "object_bytes=" << block->object_bytes() << " "
                << "frag=" << block->fragmentation_ratio()
                << "\n";

      total_objects += block->objects();
      total_object_bytes += block->object_bytes();
    }

    std::cout << blocks_seen << " blocks\n";
    std::cout << gc_.bytes_allocated() << " bytes allocated\n";
    std::cout << total_object_bytes << " object bytes / " << total_objects << " objects\n";

    int* holes = new int[10];
    for(int i = 0; i < 10; i++) {
      holes[i] = 0;
    }

    immix::AllBlockIterator iter2(chunks);

    while(immix::Block* block = iter2.next()) {
      int h = block->holes();
      if(h > 9) h = 9;

      holes[h]++;
    }

    std::cout << "== hole stats ==\n";
    for(int i = 0; i < 10; i++) {
      if(holes[i] > 0) {
        std::cout << i << ": " << holes[i] << "\n";
      }
    }
#endif
  }
Esempio n. 21
0
//------------------------------------------------------------------------------
Integer PropagationStateManager::SortVector()
{
   #ifdef DEBUG_STATE_CONSTRUCTION
      MessageInterface::ShowMessage(
            "Entered PropagationStateManager::SortVector()\n");
   #endif

   StringArray *propList;
   std::vector<Integer> order;
   std::vector<Gmat::StateElementId> idList;
   ObjectArray owners;
   StringArray property;
   std::vector<Integer>::iterator oLoc;

   Gmat::StateElementId id;
   Integer size, loc = 0, val;
   stateSize = 0;
   // Initially assume there is no post superposition member
   hasPostSuperpositionMember = false;


   #ifdef DEBUG_STATE_CONSTRUCTION
      MessageInterface::ShowMessage("Element list:\n");
      Integer k = 0;
      for (std::map<GmatBase*, StringArray*>::iterator i = elements.begin();
            i != elements.end(); ++i)
      {
         current  = i->first;
         propList = i->second;
         MessageInterface::ShowMessage("   %d: %s ->\n", ++k,
               current->GetName().c_str());
         for (UnsignedInt j = 0; j < propList->size(); ++j)
         {
            MessageInterface::ShowMessage("      %s\n", (*propList)[j].c_str());
         }
      }
   #endif

   // First build a list of the property IDs and objects, measuring state size 
   // at the same time
   for (UnsignedInt q = 0; q < objects.size(); ++q)
   {
      current  = objects[q];
      propList = elements[current];
      
      for (StringArray::iterator j = propList->begin(); 
            j != propList->end(); ++j)
      {
         id = (Gmat::StateElementId)current->SetPropItem(*j);
         if (id == Gmat::UNKNOWN_STATE)
            throw PropagatorException("Unknown state element: " + (*j) +
                  " on object " + current->GetName() + ", a " +
                  current->GetTypeName());
         size = current->GetPropItemSize(id);
         if (size <= 0)
            throw PropagatorException("State element " + (*j) +
                  " has size set less than or equal to 0; unable to continue.");
         stateSize += size;
         for (Integer k = 0; k < size; ++k)
         {
            idList.push_back(id);
            if (current->PropItemNeedsFinalUpdate(id))
               hasPostSuperpositionMember = true;
            owners.push_back(current);
            property.push_back(*j);

            // Put this item in the ordering list
            oLoc = order.begin();
            while (oLoc != order.end())
            {
               val = idList[*oLoc];
               if (id < val)
               {
                  #ifdef DEBUG_STATE_CONSTRUCTION
                     MessageInterface::ShowMessage("Inserting; id = %d, z = %d,"
                           "  loc = %d\n", id, (*oLoc), loc);
                  #endif
                     
                  order.insert(oLoc, loc);
                  break;
               }
               ++oLoc;
            }
            if (oLoc == order.end())
               order.push_back(loc);
            
            ++loc;
         }
      }
   }
   
   ListItem *newItem;
   val = 0;
   completionIndexList.clear();
   completionSizeList.clear();

   #ifdef DEBUG_STATE_CONSTRUCTION
      MessageInterface::ShowMessage(
            "State size is %d()\n", stateSize);
   #endif
   
   for (Integer i = 0; i < stateSize; ++i)
   {
      #ifdef DEBUG_STATE_CONSTRUCTION
         MessageInterface::ShowMessage("%d <- %d: %d %s.%s gives ", i, order[i], 
               idList[order[i]], owners[order[i]]->GetName().c_str(), 
               property[order[i]].c_str());
      #endif

      newItem = new ListItem;
      newItem->objectName  = owners[order[i]]->GetName();
      newItem->elementName = property[order[i]];
      if (owners[order[i]]->HasAssociatedStateObjects())
         newItem->associateName = owners[order[i]]->GetAssociateName(val);
      else
         newItem->associateName = owners[order[i]]->GetName();
      newItem->object      = owners[order[i]];
      newItem->elementID   = idList[order[i]];
      newItem->subelement  = ++val;
      newItem->parameterID = 
            owners[order[i]]->GetParameterID(property[order[i]]);
      newItem->parameterType = 
            owners[order[i]]->GetParameterType(newItem->parameterID);
      
      newItem->dynamicObjectProperty =
            newItem->object->ParameterAffectsDynamics(newItem->parameterID);

      if (newItem->parameterType == Gmat::REAL_TYPE)
         newItem->parameterID += val - 1;

      #ifdef DEBUG_STATE_CONSTRUCTION
         MessageInterface::ShowMessage("[%s, %s, %s, %d, %d, %d, %d, %s]\n",
               newItem->objectName.c_str(),
               newItem->elementName.c_str(),
               newItem->associateName.c_str(),
               newItem->elementID,
               newItem->subelement,
               newItem->parameterID,
               newItem->parameterType,
               (newItem->dynamicObjectProperty ? "dynamic" : "static"));
      #endif

      if (newItem->parameterType == Gmat::RVECTOR_TYPE)
      {
         const Rvector vec =
            owners[order[i]]->GetRvectorParameter(property[order[i]]);
         newItem->rowLength = vec.GetSize();
         newItem->rowIndex = val - 1;
      }

      if (newItem->parameterType == Gmat::RMATRIX_TYPE)
      {
         const Rmatrix mat = 
            owners[order[i]]->GetRmatrixParameter(property[order[i]]);
         newItem->rowLength = mat.GetNumColumns();
         newItem->colIndex = (val-1) % newItem->rowLength;
         newItem->rowIndex = (Integer)((val - 1) / newItem->rowLength);
         
         #ifdef DEBUG_STATE_CONSTRUCTION
            MessageInterface::ShowMessage(
                  "RowLen = %d, %d -> row %2d  col %2d\n", newItem->rowLength, 
                  val, newItem->rowIndex, newItem->colIndex); 
         #endif
      }
      
      newItem->nonzeroInit = owners[order[i]]->
            ParameterDvInitializesNonzero(newItem->parameterID,
                  newItem->rowIndex, newItem->colIndex);
      if (newItem->nonzeroInit)
      {
         newItem->initialValue = owners[order[i]]->
                ParameterDvInitialValue(newItem->parameterID,
                      newItem->rowIndex, newItem->colIndex);
      }
      if (newItem->object->PropItemNeedsFinalUpdate(newItem->elementID))
      {
         completionIndexList.push_back(newItem->elementID);
         completionSizeList.push_back(1);       // Or count sizes?
//         newItem->nonzeroInit = true;
//         newItem->initialValue = 1.0;
      }

      newItem->postDerivativeUpdate = owners[order[i]]->
            ParameterUpdatesAfterSuperposition(newItem->parameterID);


      newItem->length      = owners[order[i]]->GetPropItemSize(idList[order[i]]);
      
      if (val == newItem->length)
         val = 0;
      
      stateMap.push_back(newItem);
   }

   #ifdef DEBUG_STATE_CONSTRUCTION
      MessageInterface::ShowMessage("State map contents:\n");
      for (std::vector<ListItem*>::iterator i = stateMap.begin(); 
            i != stateMap.end(); ++i)
         MessageInterface::ShowMessage("   %s %s %d %d of %d, id = %d\n", 
               (*i)->objectName.c_str(), (*i)->elementName.c_str(),
               (*i)->elementID, (*i)->subelement, (*i)->length, 
               (*i)->parameterID); 
      MessageInterface::ShowMessage(
            "Finished PropagationStateManager::SortVector()\n");
   #endif
   
   return stateSize;
}
Esempio n. 22
0
//-------------------------------------------------------------------------
// This function is used to verify GroundStation's added hardware.
//
// return true if there is no error, false otherwise.
//-------------------------------------------------------------------------
// made changes by Tuan Nguyen
bool GroundStation::VerifyAddHardware()
{
   Gmat::ObjectType type;
   std::string subTypeName;
   GmatBase* obj;

   // 1. Verify all hardware in hardwareList are not NULL:
   for(ObjectArray::iterator i= hardwareList.begin(); i != hardwareList.end(); ++i)
   {
	   obj = (*i);
	   if (obj == NULL)
	   {
		   MessageInterface::ShowMessage("***Error***:One element of hardwareList = NULL\n");
		   return false;
	   }
   }

   // 2. Verify primary antenna to be in hardwareList:
   // 2.1. Create antenna list from hardwareList for searching:
   // extract all antenna from hardwareList and store to antennaList
   ObjectArray antennaList;
   for(ObjectArray::iterator i= hardwareList.begin(); i != hardwareList.end(); ++i)
   {
	  obj = (*i);
      subTypeName = obj->GetTypeName();
	  if (subTypeName == "Antenna")
		 antennaList.push_back(obj);
   }

   // 2.2. Verify primary antenna of Receiver, Transmitter, and Transponder:
   GmatBase* antenna;
   GmatBase* primaryAntenna;
   std::string primaryAntennaName;
   bool verify = true;
   for(ObjectArray::iterator i= hardwareList.begin(); i != hardwareList.end(); ++i)
   {
	  obj = (*i);
	  type = obj->GetType();
	  if (type == Gmat::HARDWARE)
	  {
         subTypeName = obj->GetTypeName();
         if ((subTypeName == "Transmitter")||
        	 (subTypeName == "Receiver")||
        	 (subTypeName == "Transponder"))
         {
    		 // Get primary antenna:
    		 primaryAntennaName = obj->GetRefObjectName(Gmat::HARDWARE);
    		 primaryAntenna = obj->GetRefObject(Gmat::HARDWARE,primaryAntennaName);

    		 bool check;
    		 if (primaryAntenna == NULL)
    		 {
    			 MessageInterface::ShowMessage
					 ("***Error***:primary antenna of %s in %s's AddHardware list is NULL \n",
					  obj->GetName().c_str(), this->GetName().c_str());
    			 check = false;
    		 }
    		 else
    		 {
    			 // Check primary antenna of transmitter, receiver, or transponder is in antenna list:
    			 check = false;
    			 for(ObjectArray::iterator j= antennaList.begin(); j != antennaList.end(); ++j)
    			 {
    				 antenna = (*j);
    				 if (antenna == primaryAntenna)
    				 {
    					 check = true;
    					 break;
    				 }
    				 else if (antenna->GetName() == primaryAntenna->GetName())
    				 {
    					 MessageInterface::ShowMessage
							 ("Primary antenna %s of %s is a clone of an antenna in %s's AddHardware\n",
							  primaryAntenna->GetName().c_str(), obj->GetName().c_str(), this->GetName().c_str());
    				 }
    			 }
            	 if (check == false)
            	 {
            		 // Display error message:
            		 MessageInterface::ShowMessage
							 ("***Error***:primary antenna of %s is not in %s's AddHardware\n",
							  obj->GetName().c_str(), this->GetName().c_str());
            	 }

        	 }

        	 verify = verify && check;
         }
	  }
   }

   return verify;
}
Esempio n. 23
0
	void Done()
	{
		m_items.free();
	}
Esempio n. 24
0
/*****************************************************
**
**   BasicVedicChart   ---   writeChartContents
**
******************************************************/
void BasicVedicChart::writeChartContents( const int &chart_id, const bool applyFilter )
{
	ObjectId planet;
	uint f;
	wxString lname, sname, symbol, av;
	bool retro, avmode;
	SymbolProvider sp;
	SheetFormatter fmt;

	if ( chart_id == 0 && ! h1set ) printf( "WARN BasicVedicChart::writeChartContents no chart set for id 0\n" );
	if ( chart_id == 1 && ! h2set ) printf( "WARN BasicVedicChart::writeChartContents no chart set for id 1\n" );

	ObjectArray o = applyFilter ? chartprops->getVedicPlanetList( chartprops->getObjectFilter()) : obs;
	for ( uint i = 0; i < o.size(); i++ )
	{
		planet = o[i];

		// do not paint ascendant in north indian chart
		if ( field_count == 12 && chart_id == 0 && planet == OASCENDANT && chartprops->getVedicChartDisplayConfig().indianChartType == VCT_NORTH ) continue;

		// do not paint ascendant in south indian chart if markup of AS is enabled
		if ( field_count == 12 && ! h2set && planet == OASCENDANT && chartprops->getVedicChartDisplayConfig().southIndianAscendantMarkup ) continue;

		f = a_red( getPlanetField( planet, chart_id ) - positionOffset, field_count );
		//printf( "positionOffset %d\n", positionOffset );
		assert( f < fields.size());

		ChartContents &cc = fields[f].getContents( chart_id );

		cc.planets.push_back( planet );

		lname = fmt.getObjectNamePlain( planet, TF_LONG, true );
		sname = fmt.getObjectNamePlain( planet, TF_MEDIUM, true );

		// retrogression
		retro = ( chartprops->getVedicChartDisplayConfig().showRetro ) && getPlanetRetro( planet, chart_id )
		        && planet != OMEANNODE && planet != OMEANDESCNODE;
		if ( retro )
		{
			//lname += wxT( " " );
			lname += wxT( "(R)" );
			sname += wxT( "R" );
		}

		// see if transit mode, varga, av and valid planet
		avmode = ( IS_AVPLANET( planet )
			&& charttype == CT_TRANSIT
			&& chart_id == 1
			&& field_count == 12
			&& chartprops->getVedicChartDisplayConfig().showAshtakavarga );

		if ( avmode )
		{
			av = wxString::Format( wxT( " %d" ), getAshtakavargaPoints( planet, f ));
			sname += av;
			lname += av;
		}

		// symbol
		symbol.Clear();
		if ( ! avmode && config->writer->planetSymbols && getVChartConfig()->useSymbols && planet <= MAX_EPHEM_OBJECTS ) symbol = sp.getPlanetCode( planet );
		if ( ! symbol.IsEmpty() )
		{
			cc.graphicitems.push_back( ChartGraphicItem( symbol, planet, retro ));
		}
		else
		{
			ChartTextItem item( lname, sname, retro );
			cc.textitems.push_back( item );
		}
	}
}
Esempio n. 25
0
 void promoted_push(Object* obj) {
   promoted_objects_++;
   promoted_stack_.push_back(obj);
 }
Esempio n. 26
0
//------------------------------------------------------------------------------
// bool SetTankFromSpacecraft()
//------------------------------------------------------------------------------
bool ImpulsiveBurn::SetTankFromSpacecraft()
{
   #ifdef DEBUG_IMPBURN_SET
   MessageInterface::ShowMessage
      ("ImpulsiveBurn::SetTankFromSpacecraft() entered, spacecraft=<%p>'%s'\n",
       spacecraft, spacecraft ? spacecraft->GetName().c_str() : "NULL");
   MessageInterface::ShowMessage("   tankNames.size()=%d\n", tankNames.size());
   #endif
   
   if (spacecraft == NULL)
      return false;
   
   if (tankNames.empty())
      throw BurnException("ImpulsiveBurn::Initialize() " + instanceName +
                          " has no associated tank");
   
   ObjectArray tankArray = spacecraft->GetRefObjectArray(Gmat::FUEL_TANK);
   
   #ifdef DEBUG_IMPBURN_SET
   MessageInterface::ShowMessage
      ("   spacecraft tankArray.size()=%d\n", tankArray.size());
   #endif
   
   if (!tankNames.empty() && !tankArray.empty())
   {
      ObjectArray::iterator scTank = tankArray.begin();
      
      // Find the tank on the spacecraft
      for (StringArray::iterator tankName = tankNames.begin();
           tankName != tankNames.end(); ++tankName)
      {
         while (scTank != tankArray.end())
         {
            #ifdef DEBUG_IMPBURN_SET
            MessageInterface::ShowMessage
               ("   The tank '%s' associated with spacecraft is <%p>'%s'\n",
                (*tankName).c_str(), (*scTank),
                (*scTank) ? (*scTank)->GetName().c_str() : "NULL");
            #endif
            
            // Just in case, check for NULL tank pointer
            if (*scTank == NULL)
               continue;
            
            // Assign the tank
            if ((*scTank)->GetName() == *tankName)
            {
               tankMap[*tankName] = (*scTank);
               #ifdef DEBUG_IMPBURN_SET
               MessageInterface::ShowMessage
                  ("   Assigned <%p>'%s' to tankMap\n", *scTank, (*tankName).c_str());
               #endif
            }
            ++scTank;
         }
      }
      if (tankNames.size() != tankMap.size())
         throw BurnException("The impulsive burn " + instanceName +
               " could not find the fuel tank needed to deplete mass; please "
               "attach the tank to the spacecraft " + spacecraft->GetName() +
               " or turn off mass depletion.");
   }
   
   #ifdef DEBUG_IMPBURN_SET
   MessageInterface::ShowMessage
      ("ImpulsiveBurn::SetTankFromSpacecraft() returning true\n");
   #endif
   
   return true;
}
Esempio n. 27
0
//------------------------------------------------------------------------------
void BatchEstimator::CompleteInitialization()
{
   #ifdef WALK_STATE_MACHINE
      MessageInterface::ShowMessage("BatchEstimator state is INITIALIZING\n");
   #endif

   if (showAllResiduals)
   {
      StringArray plotMeasurements;
      for (UnsignedInt i = 0; i < measurementNames.size(); ++i)
      {
         plotMeasurements.clear();
         plotMeasurements.push_back(measurementNames[i]);
         std::string plotName = instanceName + "_" + measurementNames[i] +
               "_Residuals";
         BuildResidualPlot(plotName, plotMeasurements);
      }
   }

   if (advanceToEstimationEpoch == false)
   {
      PropagationStateManager *psm = propagator->GetPropStateManager();
      GmatState               *gs  = psm->GetState();
      estimationState              = esm.GetState();
      stateSize = estimationState->GetSize();

      Estimator::CompleteInitialization();

      // If estimation epoch not set, use the epoch from the prop state
      if ((estEpochFormat == "FromParticipants") || (estimationEpoch <= 0.0))
      {
         ObjectArray participants;
         esm.GetStateObjects(participants, Gmat::SPACEOBJECT);
         for (UnsignedInt i = 0; i < participants.size(); ++i)
            estimationEpoch   = ((SpaceObject *)(participants[i]))->GetEpoch();
      }
      currentEpoch         = gs->GetEpoch();

      // Tell the measManager to complete its initialization
      bool measOK = measManager.Initialize();
      if (!measOK)
         throw SolverException(
               "BatchEstimator::CompleteInitialization - error initializing "
               "MeasurementManager.\n");

      // Now load up the observations
      measManager.PrepareForProcessing();
      measManager.LoadObservations();

      if (!GmatMathUtil::IsEqual(currentEpoch, estimationEpoch))
      {
         advanceToEstimationEpoch = true;
         nextMeasurementEpoch = estimationEpoch;
         currentState = PROPAGATING;
         return;
      }
   }

   advanceToEstimationEpoch = false;

   // First measurement epoch is the epoch of the first measurement.  Duh.
   nextMeasurementEpoch = measManager.GetEpoch();

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage(
            "Init complete!\n   STM = %s\n   Covariance = %s\n",
            stm->ToString().c_str(), covariance->ToString().c_str());
   #endif

   hAccum.clear();
   if (useApriori)
   {
      information = stateCovariance->GetCovariance()->Inverse();
   }
   else
   {
      information.SetSize(stateSize, stateSize);
      for (UnsignedInt i = 0; i <  stateSize; ++i)
         for (UnsignedInt j = 0; j <  stateSize; ++j)
            information(i,j) = 0.0;
   }

   residuals.SetSize(stateSize);
   x0bar.SetSize(stateSize);

   measurementResiduals.clear();
   measurementEpochs.clear();

   for (Integer i = 0; i < information.GetNumRows(); ++i)
   {
      residuals[i] = 0.0;
      if (useApriori)
         x0bar[i] = (*estimationState)[i];
      else
         x0bar[i] = 0.0;
   }

   if (useApriori)
      for (Integer i = 0; i < information.GetNumRows(); ++i)
      {
         for (UnsignedInt j = 0; j < stateSize; ++j)
            residuals[i] += information(i,j) * x0bar[j];
      }

   esm.BufferObjects(&outerLoopBuffer);
   esm.MapObjectsToVector();

   converged   = false;
   isInitialized = true;

   WriteToTextFile();
   ReportProgress();

   if (GmatMathUtil::IsEqual(currentEpoch, nextMeasurementEpoch))
      currentState = CALCULATING;
   else
   {
      timeStep = (nextMeasurementEpoch - currentEpoch) *
            GmatTimeConstants::SECS_PER_DAY;
      currentState = PROPAGATING;
   }

   #ifdef DEBUG_INITIALIZATION
      MessageInterface::ShowMessage("BatchEstimator::CompleteInitialization "
            "process complete\n");
      MessageInterface::ShowMessage("   Estimation state = [");
      for (UnsignedInt i = 0; i < stateSize; ++i)
         MessageInterface::ShowMessage(" %.12lf ", (*estimationState)[i]);
      MessageInterface::ShowMessage("]\n");
      MessageInterface::ShowMessage("   Information Matrix = \n");
      for (Integer i = 0; i < information.GetNumRows(); ++i)
      {
         MessageInterface::ShowMessage("      [");
         for (Integer j = 0; j < information.GetNumColumns(); ++j)
         {
            MessageInterface::ShowMessage(" %.12lf ", information(i, j));
         }
         MessageInterface::ShowMessage("]\n");
      }
      MessageInterface::ShowMessage("   Residuals = [");
      for (Integer i = 0; i < residuals.GetSize(); ++i)
         MessageInterface::ShowMessage(" %.12lf ", residuals[i]);
      MessageInterface::ShowMessage("]\n");
   #endif
}
Esempio n. 28
0
  void ObjectWalker::seed(GCData& data) {
    Object* tmp;
    ObjectArray *current_rs = object_memory_->remember_set();

    for(ObjectArray::iterator oi = current_rs->begin();
        oi != current_rs->end();
        ++oi) {
      tmp = *oi;
      // unremember_object throws a NULL in to remove an object
      // so we don't have to compact the set in unremember
      if(tmp) saw_object(tmp);
    }

    for(std::list<gc::WriteBarrier*>::iterator wbi = object_memory_->aux_barriers().begin();
        wbi != object_memory_->aux_barriers().end();
        ++wbi) {
      gc::WriteBarrier* wb = *wbi;
      ObjectArray* rs = wb->remember_set();
      for(ObjectArray::iterator oi = rs->begin();
          oi != rs->end();
          ++oi) {
        tmp = *oi;

        if(tmp) saw_object(tmp);
      }
    }

    for(Roots::Iterator i(data.roots()); i.more(); i.advance()) {
      saw_object(i->get());
    }

    if(data.threads()) {
      for(std::list<ManagedThread*>::iterator i = data.threads()->begin();
          i != data.threads()->end();
          ++i) {
        for(Roots::Iterator ri((*i)->roots()); ri.more(); ri.advance()) {
          saw_object(ri->get());
        }
      }
    }

    for(capi::Handles::Iterator i(*data.handles()); i.more(); i.advance()) {
      saw_object(i->object());
    }

    for(capi::Handles::Iterator i(*data.cached_handles()); i.more(); i.advance()) {
      saw_object(i->object());
    }

    for(VariableRootBuffers::Iterator i(data.variable_buffers());
        i.more(); i.advance()) {
      Object*** buffer = i->buffer();
      for(int idx = 0; idx < i->size(); idx++) {
        Object** var = buffer[idx];
        Object* tmp = *var;

        saw_object(tmp);
      }
    }

    RootBuffers* rb = data.root_buffers();
    if(rb) {
      for(RootBuffers::Iterator i(*rb);
          i.more();
          i.advance())
      {
        Object** buffer = i->buffer();
        for(int idx = 0; idx < i->size(); idx++) {
          saw_object(buffer[idx]);
        }
      }
    }

    // Walk all the call frames
    for(CallFrameLocationList::iterator i = data.call_frames().begin();
        i != data.call_frames().end();
        ++i) {
      CallFrame** loc = *i;
      walk_call_frame(*loc);
    }
  }
Esempio n. 29
0
  /**
   * Perform garbage collection on the young objects.
   */
  void BakerGC::collect(GCData& data, YoungCollectStats* stats) {

#ifdef HAVE_VALGRIND_H
    VALGRIND_MAKE_MEM_DEFINED(next->start().as_int(), next->size());
    VALGRIND_MAKE_MEM_DEFINED(current->start().as_int(), current->size());
#endif

    Object* tmp;
    ObjectArray *current_rs = object_memory_->swap_remember_set();

    total_objects = 0;

    copy_spills_ = 0;
    reset_promoted();

    // Start by copying objects in the remember set
    for(ObjectArray::iterator oi = current_rs->begin();
        oi != current_rs->end();
        ++oi) {
      tmp = *oi;
      // unremember_object throws a NULL in to remove an object
      // so we don't have to compact the set in unremember
      if(tmp) {
        // assert(tmp->mature_object_p());
        // assert(!tmp->forwarded_p());

        // Remove the Remember bit, since we're clearing the set.
        tmp->clear_remember();
        scan_object(tmp);
      }
    }

    delete current_rs;

    for(std::list<gc::WriteBarrier*>::iterator wbi = object_memory_->aux_barriers().begin();
        wbi != object_memory_->aux_barriers().end();
        ++wbi) {
      gc::WriteBarrier* wb = *wbi;
      ObjectArray* rs = wb->swap_remember_set();
      for(ObjectArray::iterator oi = rs->begin();
          oi != rs->end();
          ++oi) {
        tmp = *oi;

        if(tmp) {
          tmp->clear_remember();
          scan_object(tmp);
        }
      }

      delete rs;
    }

    for(Roots::Iterator i(data.roots()); i.more(); i.advance()) {
      i->set(saw_object(i->get()));
    }

    if(data.threads()) {
      for(std::list<ManagedThread*>::iterator i = data.threads()->begin();
          i != data.threads()->end();
          ++i) {
        scan(*i, true);
      }
    }

    for(Allocator<capi::Handle>::Iterator i(data.handles()->allocator()); i.more(); i.advance()) {
      if(!i->in_use_p()) continue;

      if(!i->weak_p() && i->object()->young_object_p()) {
        i->set_object(saw_object(i->object()));

      // Users manipulate values accessible from the data* within an
      // RData without running a write barrier. Thusly if we see a mature
      // rdata, we must always scan it because it could contain
      // young pointers.
      } else if(!i->object()->young_object_p() && i->is_rdata()) {
        scan_object(i->object());
      }

      assert(i->object()->type_id() > InvalidType && i->object()->type_id() < LastObjectType);
    }

    std::list<capi::GlobalHandle*>* gh = data.global_handle_locations();

    if(gh) {
      for(std::list<capi::GlobalHandle*>::iterator i = gh->begin();
          i != gh->end();
          ++i) {
        capi::GlobalHandle* global_handle = *i;
        capi::Handle** loc = global_handle->handle();
        if(capi::Handle* hdl = *loc) {
          if(!REFERENCE_P(hdl)) continue;
          if(hdl->valid_p()) {
            Object* obj = hdl->object();
            if(obj && obj->reference_p() && obj->young_object_p()) {
              hdl->set_object(saw_object(obj));
            }
          } else {
            std::cerr << "Detected bad handle checking global capi handles\n";
          }
        }
      }
    }

#ifdef ENABLE_LLVM
    if(LLVMState* ls = data.llvm_state()) ls->gc_scan(this);
#endif

    // Handle all promotions to non-young space that occurred.
    handle_promotions();

    assert(fully_scanned_p());
    // We're now done seeing the entire object graph of normal, live references.
    // Now we get to handle the unusual references, like finalizers and such.

    // Objects with finalizers must be kept alive until the finalizers have
    // run.
    walk_finalizers();

    // Process possible promotions from processing objects with finalizers.
    handle_promotions();

    if(!promoted_stack_.empty()) rubinius::bug("promote stack has elements!");
    if(!fully_scanned_p()) rubinius::bug("more young refs");

    // Check any weakrefs and replace dead objects with nil
    clean_weakrefs(true);

    // Swap the 2 halves
    Heap *x = next;
    next = current;
    current = x;

    if(stats) {
      stats->lifetime = lifetime_;
      stats->percentage_used = current->percentage_used();
      stats->promoted_objects = promoted_objects_;
      stats->excess_objects = copy_spills_;
    }

    // Tune the age at which promotion occurs
    if(autotune_) {
      double used = current->percentage_used();
      if(used > cOverFullThreshold) {
        if(tune_threshold_ >= cOverFullTimes) {
          if(lifetime_ > cMinimumLifetime) lifetime_--;
        } else {
          tune_threshold_++;
        }
      } else if(used < cUnderFullThreshold) {
        if(tune_threshold_ <= cUnderFullTimes) {
          if(lifetime_ < cMaximumLifetime) lifetime_++;
        } else {
          tune_threshold_--;
        }
      } else if(tune_threshold_ > 0) {
        tune_threshold_--;
      } else if(tune_threshold_ < 0) {
        tune_threshold_++;
      } else if(tune_threshold_ == 0) {
        if(lifetime_ < original_lifetime_) {
          lifetime_++;
        } else if(lifetime_ > original_lifetime_) {
          lifetime_--;
        }
      }
    }

  }
Esempio n. 30
0
void TextData::reloadFile()
{
    File file(this->fileName);

    long oldLength = getLength();
    long oldNumberLines = this->numberLines;

    ObjectArray<LineAndColumn> oldMarkPositions;

    for (long i = 0; i < marks.getLength(); ++i) {
        if (marks[i].inUseCounter > 0) {
            oldMarkPositions.append(LineAndColumn(marks[i].line,
                                                  getWCharColumn(marks[i])));
        } else {
            oldMarkPositions.append(LineAndColumn(0, 0));
        }
    }
    
    Nullable<FileException> fileException;
    try {
        file.loadInto(&buffer);
    } catch (FileException& ex) {
        fileException = ex;
    }

    EncodingConverter c(fileContentEncoding, "UTF-8");
    
    if (c.isConvertingBetweenDifferentCodesets())
    {
        c.convertInPlace(&buffer);
    }

    long len = buffer.getLength();
    byte* ptr = buffer.getTotalAmount();

    this->numberLines = 1;
    for (long i = 0; i < len; ++i) {
        if (ptr[i] == '\n') {
            ++this->numberLines;
        }
    }
    this->beginChangedPos = 0;
    this->changedAmount = len - oldLength;
    this->oldEndChangedPos = oldLength;
    
    updateMarks(0, oldLength, len - oldLength,           // long beginChangedPos, long oldEndChangedPos, long changedAmount,
                0, this->numberLines - oldNumberLines);  // long beginLineNumber, long changedLineNumberAmount)

    for (long i = 0; i < marks.getLength(); ++i) {
        if (marks[i].inUseCounter > 0) {
            moveMarkToLineAndWCharColumn(MarkHandle(i), oldMarkPositions[i].line,
                                                        oldMarkPositions[i].wcharColumn);
        }
    }
    setModifiedFlag(false);

    this->fileInfo = file.getInfo();
    this->modifiedOnDiskFlag = false;
    this->ignoreModifiedOnDiskFlag = false;

    if (!fileException.isValid()) {
        if (isReadOnlyFlag != !fileInfo.isWritable()) {
            isReadOnlyFlag = !fileInfo.isWritable();
            readOnlyListeners.invokeAllCallbacks(isReadOnlyFlag);
        }
        clearHistory();
    }
    if (fileException.isValid()) {
        throw fileException.get();
    }
}