Esempio n. 1
0
bool Game::Update(GameTime)
{
	time.StartFrame();

	SDL_LockAudio();
	{
		ParseInput();
		if (Transitioning())
		{
			Transist();
		}
		else if (phase)
		{
			phase->Update(time);
		}
	}
	SDL_UnlockAudio();

	GetFactory()->Purge();

	if (finished)
	{
		SDL_CloseAudio();
	}

	return !finished;
}
bool LevelWorkerGameObjects::RemoveFeature()
{
    // Remove this worker from the ID->Worker map maintained by the factory.
    GetFactory()->ClearWorkerForObject(m_pGo->GetId());
    // Remove the object.
    Engine::Instance()->ClearGameObject(m_pGo->GetId());
    return true;
}
  void RebalanceMapFactory<LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level & currentLevel) const {
    const Teuchos::ParameterList & pL = GetParameterList();
    std::string mapName                        = pL.get<std::string> ("Map name");
    Teuchos::RCP<const FactoryBase> mapFactory = GetFactory          ("Map factory");
    currentLevel.DeclareInput(mapName,mapFactory.get(),this);

    Input(currentLevel, "Importer");
  } //DeclareInput()
Esempio n. 4
0
bool pgCollection::IsCollectionFor(pgObject *obj)
{
	if (!obj)
		return false;
	pgaFactory *f = obj->GetFactory();
	if (!f)
		return false;
	return GetFactory() == f->GetCollectionFactory();
}
  void SaPFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level &fineLevel, Level &coarseLevel) const {
    Input(fineLevel, "A");

    // Get default tentative prolongator factory
    // Getting it that way ensure that the same factory instance will be used for both SaPFactory and NullspaceFactory.
    RCP<const FactoryBase> initialPFact = GetFactory("P");
    if (initialPFact == Teuchos::null) { initialPFact = coarseLevel.GetFactoryManager()->GetFactory("Ptent"); }
    coarseLevel.DeclareInput("P", initialPFact.get(), this); // --
  }
  void RebalanceMapFactory<LocalOrdinal, GlobalOrdinal, Node>::Build(Level &level) const {
    FactoryMonitor m(*this, "Build", level);

    //Teuchos::RCP<Teuchos::FancyOStream> fos = Teuchos::getFancyOStream(Teuchos::rcpFromRef(std::cout));

    // extract data from Level object
    const Teuchos::ParameterList & pL = GetParameterList();
    std::string mapName = pL.get<std::string> ("Map name");
    Teuchos::RCP<const FactoryBase> mapFactory = GetFactory ("Map factory");

    RCP<const Import> rebalanceImporter = Get<RCP<const Import> >(level, "Importer");

    if(rebalanceImporter != Teuchos::null) {
      // input map (not rebalanced)
      RCP<const Map> map = level.Get< RCP<const Map> >(mapName,mapFactory.get());

      // create vector based on input map
      // Note, that the map can be a part only of the full map stored in rebalanceImporter.getSourceMap()
      RCP<Vector> v = VectorFactory::Build(map);
      v->putScalar(1.0);

      // create a new vector based on the full rebalanceImporter.getSourceMap()
      // import the partial map information to the full source map
      RCP<const Import> blowUpImporter = ImportFactory::Build(map, rebalanceImporter->getSourceMap());
      RCP<Vector> pv = VectorFactory::Build(rebalanceImporter->getSourceMap());
      pv->doImport(*v,*blowUpImporter,Xpetra::INSERT);

      // do rebalancing using rebalanceImporter
      RCP<Vector> ptv = VectorFactory::Build(rebalanceImporter->getTargetMap());
      ptv->doImport(*pv,*rebalanceImporter,Xpetra::INSERT);

      if (pL.get<bool>("repartition: use subcommunicators") == true)
        ptv->replaceMap(ptv->getMap()->removeEmptyProcesses());

      // reconstruct rebalanced partial map
      Teuchos::ArrayRCP< const Scalar > ptvData = ptv->getData(0);
      std::vector<GlobalOrdinal> localGIDs;  // vector with GIDs that are stored on current proc

      for (size_t k = 0; k < ptv->getLocalLength(); k++) {
        if(ptvData[k] == 1.0) {
          localGIDs.push_back(ptv->getMap()->getGlobalElement(k));
        }
      }

      const Teuchos::ArrayView<const GlobalOrdinal> localGIDs_view(&localGIDs[0],localGIDs.size());

      Teuchos::RCP<const Map> localGIDsMap = MapFactory::Build(
          map->lib(),
          Teuchos::OrdinalTraits<int>::invalid(),
          localGIDs_view,
          0, ptv->getMap()->getComm());  // use correct communicator here!

      // store rebalanced partial map using the same name and generating factory as the original map
      // in the level class
      level.Set(mapName, localGIDsMap, mapFactory.get());
    }
  } //Build()
Esempio n. 7
0
//---------------------------------------------------------------------------
// 初期化
bool TModuleJava::Initialize(void){
	JavaVM *vm; JNIEnv *env;
	if (JNI_OK!=setup(GetFactory().GetLogger(), &vm, &env)) return false;

	obj_saori=(jobject)handle;
	jclass lref_cls=env->GetObjectClass(obj_saori);
	cls_saori=(jclass)env->NewGlobalRef(lref_cls);

	mid_load=env->GetMethodID(cls_saori, "load", "([B)Z");
	mid_unload=env->GetMethodID(cls_saori, "unload", "()Z");
	mid_request=env->GetMethodID(cls_saori, "request", "([B)[B");

	if (mid_request==NULL){
		GetFactory().GetLogger().GetStream(LOG_ERROR) << "[SAORI Java] importing 'request' from ("+path+") failed." << endl;
		return false;
	}
	return true;
}
 void RigidBodyModeFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level &currentLevel) const {
   if (currentLevel.IsAvailable(nspName_, NoFactory::get()) == false && currentLevel.GetLevelID() == 0) {
     Input(currentLevel, "A");
     //Input(currentLevel,"Coordinates");
   }
   if (currentLevel.GetLevelID() !=0) {
     currentLevel.DeclareInput("Nullspace", GetFactory(nspName_).get(), this); /* ! "Nullspace" and nspName_ mismatch possible here */
   }
 }
Esempio n. 9
0
//---------------------------------------------------------------------------
// SAORI/1.0 Load
bool TModuleJava::Load(void){
	if (!mid_load) return TRUE;

	JavaVM *vm; JNIEnv *env;
	if (JNI_OK!=setup(GetFactory().GetLogger(), &vm, &env)) return false;

	jobject obj_saori=(jobject)handle;

	string basepath;
	unsigned int pos=path.find_last_of(FILE_SEPARATOR);
	if (pos==string::npos){
		basepath=path+FILE_SEPARATOR;
	}else{
		basepath=path.substr(0, pos+1);
	}

	GetFactory().GetLogger().GetStream(LOG_INFO) << "[SAORI Java] load(" << basepath << ")." << endl;
	return (env->CallBooleanMethod(obj_saori, mid_load, string2jba(env, basepath))==JNI_TRUE);
}
IGameComponent* GameComponentCreator::CreateObject(const core::string&name,GameEntityManager*mngr)
{
	IGameComponentFactory* f= GetFactory(name);
	if(!f)
	{
		gLogManager.log(mT("Game Component Factory with type: '")+name+mT("' was not found"),ELL_WARNING,EVL_Normal);
		return 0;
	}
	return f->CreateComponent(mngr);
}
void PermutationFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level &currentLevel) const {
  Input(currentLevel, "A");

  const ParameterList & pL = GetParameterList();
  std::string mapName                        = pL.get<std::string> ("PermutationRowMapName");
  Teuchos::RCP<const FactoryBase> mapFactory = GetFactory          ("PermutationRowMapFactory");

  if(mapName.length() > 0 ) {
    currentLevel.DeclareInput(mapName,mapFactory.get(),this);
  }
}
Esempio n. 12
0
//---------------------------------------------------------------------------
// SAORI/1.0 Request
string TModuleJava::Request(const string &req){
	if (!mid_request) return ("");

	JavaVM *vm; JNIEnv *env;
	if (JNI_OK!=setup(GetFactory().GetLogger(), &vm, &env)) return ("");

	jobject obj_saori=(jobject)handle;

	return jba2string(env, (jbyteArray)env->CallObjectMethod(
		obj_saori, mid_request, string2jba(env, req)));
}
Esempio n. 13
0
void Ghost::Process()
{
    --seconds_until_respawn_;
    if (seconds_until_respawn_ < 0)
    {
        size_t net_id = GetFactory().GetNetId(GetId());
        if (net_id)
        {
            auto login_mob = GetFactory().Create<IMob>(LoginMob::T_ITEM_S());

            GetFactory().SetPlayerId(net_id, login_mob.ret_id());
            if (GetId() == GetMob().ret_id())
            {
                ChangeMob(login_mob);
            }
            delThis();
            //qDebug() << "Ghost deleted: net_id: " << net_id;
        }
    }
}
Esempio n. 14
0
pgaFactory *pgaFactory::GetFactoryByMetaType(const int type)
{
	int i;
	pgaFactory *factory;

	for (i = FACTORY_OFFSET ; (factory = GetFactory(i)) != 0 ; i++)
	{
		if (factory->GetMetaType() == type)
			return factory;
	}
	return 0;
}
Esempio n. 15
0
void Grille::AttackBy(id_ptr_on<Item> item)
{
    if (id_ptr_on<Wirecutters> w = item)
    {
        PlaySoundIfVisible("Wirecutter.ogg", owner.ret_id());
        if (!cutted_)
        {
            SetState("brokengrille");
            SetPassable(D_ALL, Passable::FULL);
            cutted_ = true;
            GetFactory().Create<IOnMapObject>(Rod::T_ITEM_S(), GetOwner());
        }
        else
        {
            GetFactory().Create<IOnMapObject>(Rod::T_ITEM_S(), GetOwner());
            delThis();
        }
    }
    else
        Structure::AttackBy(item);
}
  void UncoupledAggregationFactory<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::DeclareInput(Level& currentLevel) const {
    Input(currentLevel, "Graph");
    Input(currentLevel, "DofsPerNode");

    const ParameterList& pL = GetParameterList();

    std::string mapOnePtName = pL.get<std::string>("OnePt aggregate map name");
    if (mapOnePtName.length() > 0) {
      RCP<const FactoryBase> mapOnePtFact = GetFactory("OnePt aggregate map factory");
      currentLevel.DeclareInput(mapOnePtName, mapOnePtFact.get());
    }
  }
Esempio n. 17
0
    void Set(const std::string & ename, const T &entry, const FactoryBase* factory = NoFactory::get()) {
      const FactoryBase* fac = GetFactory(ename, factory);

      if (fac == NoFactory::get()) {
        // user defined data
        // keep data
        AddKeepFlag(ename, NoFactory::get(), MueLu::UserData);
      }

      needs_.Set<T>(ename, entry, fac);

    } // Set
Esempio n. 18
0
pgaFactory *pgaFactory::GetFactory(const wxString &name)
{
	int i;
	pgaFactory *factory;

	for (i = FACTORY_OFFSET ; (factory = GetFactory(i)) != 0 ; i++)
	{
		if (name.Matches(factory->GetTypeName()))
			return factory;
	}
	return 0;
}
Esempio n. 19
0
//-----------------------------------------------------------------------------
// Create all singleton systems
//-----------------------------------------------------------------------------
bool CHLModelViewerApp::Create()
{
	SpewOutputFunc( HLMVSpewFunc );

	g_dxlevel = CommandLine()->ParmValue( "-dx", 0 );
	g_bOldFileDialogs = ( CommandLine()->FindParm( "-olddialogs" ) != 0 );

	AppSystemInfo_t appSystems[] = 
	{
		{ "materialsystem.dll",		MATERIAL_SYSTEM_INTERFACE_VERSION },
		{ "studiorender.dll",		STUDIO_RENDER_INTERFACE_VERSION },
		{ "vphysics.dll",			VPHYSICS_INTERFACE_VERSION },
		{ "datacache.dll",			DATACACHE_INTERFACE_VERSION },
		{ "datacache.dll",			MDLCACHE_INTERFACE_VERSION },
		{ "datacache.dll",			STUDIO_DATA_CACHE_INTERFACE_VERSION },
		{ "soundemittersystem.dll",	SOUNDEMITTERSYSTEM_INTERFACE_VERSION },
		{ "soundsystem.dll",		SOUNDSYSTEM_INTERFACE_VERSION },

		{ "", "" }	// Required to terminate the list
	};

	if ( !AddSystems( appSystems ) ) 
		return false;

	g_pFileSystem = (IFileSystem*)FindSystem( FILESYSTEM_INTERFACE_VERSION );
	g_pMaterialSystem = (IMaterialSystem*)FindSystem( MATERIAL_SYSTEM_INTERFACE_VERSION );
	g_pMaterialSystemHardwareConfig = (IMaterialSystemHardwareConfig*)FindSystem( MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION );
	g_pStudioRender = (IStudioRender*)FindSystem( STUDIO_RENDER_INTERFACE_VERSION );
	g_pDataCache = (IDataCache*)FindSystem( DATACACHE_INTERFACE_VERSION );
	g_pMDLCache = (IMDLCache*)FindSystem( MDLCACHE_INTERFACE_VERSION );
	g_pStudioDataCache = (IStudioDataCache*)FindSystem( STUDIO_DATA_CACHE_INTERFACE_VERSION ); 
	physcollision = (IPhysicsCollision *)FindSystem( VPHYSICS_COLLISION_INTERFACE_VERSION );
	physprop = (IPhysicsSurfaceProps *)FindSystem( VPHYSICS_SURFACEPROPS_INTERFACE_VERSION );
	g_pSoundEmitterBase = (ISoundEmitterSystemBase *)FindSystem( SOUNDEMITTERSYSTEM_INTERFACE_VERSION );
	g_pSoundSystem = (ISoundSystem *)FindSystem( SOUNDSYSTEM_INTERFACE_VERSION );

	if ( !g_pFileSystem || !physprop || !physcollision || !g_pMaterialSystem || !g_pStudioRender || !g_pMDLCache || !g_pDataCache )
	{
		Error("Unable to load required library interface!\n");
	}

	const char *pShaderDLL = CommandLine()->ParmValue("-shaderdll");
	if(!pShaderDLL)
	{
		pShaderDLL = "shaderapidx9.dll";
	}
	g_pMaterialSystem->SetShaderAPI( pShaderDLL );

	g_Factory = GetFactory();

	return true;
}
Esempio n. 20
0
bool CDmxConvertApp::PreInit( )
{
	CreateInterfaceFn factory = GetFactory();
	ConnectTier1Libraries( &factory, 1 );
	ConnectTier2Libraries( &factory, 1 );

	if ( !g_pFullFileSystem || !g_pDataModel )
	{
		Warning( "DMXConvert is missing a required interface!\n" );
		return false;
	}
	return true;
}
Esempio n. 21
0
  void MapTransferFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::Build(Level & fineLevel, Level & coarseLevel) const {
    typedef Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node, LocalMatOps> OperatorClass; //TODO
    typedef Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node> MapClass;
    typedef Xpetra::MapFactory<LocalOrdinal, GlobalOrdinal, Node> MapFactoryClass;

    Monitor m(*this, "Contact Map transfer factory");

    if (fineLevel.IsAvailable(mapName_, mapFact_.get())==false) {
        GetOStream(Runtime0, 0) << "MapTransferFactory::Build: User provided map " << mapName_ << " not found in Level class." << std::endl;
    }

    // fetch map extractor from level
    RCP<const MapClass> transferMap = fineLevel.Get<RCP<const MapClass> >(mapName_,mapFact_.get());

    // Get default tentative prolongator factory
    // Getting it that way ensure that the same factory instance will be used for both SaPFactory and NullspaceFactory.
    // -- Warning: Do not use directly initialPFact_. Use initialPFact instead everywhere!
    RCP<const FactoryBase> tentPFact = GetFactory("P");
    if (tentPFact == Teuchos::null) { tentPFact = coarseLevel.GetFactoryManager()->GetFactory("Ptent"); }
    TEUCHOS_TEST_FOR_EXCEPTION(!coarseLevel.IsAvailable("P",tentPFact.get()),Exceptions::RuntimeError, "MueLu::MapTransferFactory::Build(): P (generated by TentativePFactory) not available.");
    RCP<OperatorClass> Ptent = coarseLevel.Get<RCP<OperatorClass> >("P", tentPFact.get());

    std::vector<GlobalOrdinal > coarseMapGids;

    // loop over local rows of Ptent
    for(size_t row=0; row<Ptent->getNodeNumRows(); row++) {

      GlobalOrdinal grid = Ptent->getRowMap()->getGlobalElement(row);
      if(transferMap->isNodeGlobalElement(grid)) {

        Teuchos::ArrayView<const LocalOrdinal> indices;
        Teuchos::ArrayView<const Scalar> vals;
        Ptent->getLocalRowView(row, indices, vals);

        for(size_t i=0; i<(size_t)indices.size(); i++) {
          // mark all columns in Ptent(grid,*) to be coarse Dofs of next level transferMap
          GlobalOrdinal gcid = Ptent->getColMap()->getGlobalElement(indices[i]);
          coarseMapGids.push_back(gcid);
        }
      } // end if isNodeGlobalElement(grid)
    }

    // build column maps
    std::sort(coarseMapGids.begin(), coarseMapGids.end());
    coarseMapGids.erase(std::unique(coarseMapGids.begin(), coarseMapGids.end()), coarseMapGids.end());
    Teuchos::ArrayView<GlobalOrdinal> coarseMapGidsView (&coarseMapGids[0],coarseMapGids.size());
    Teuchos::RCP<const MapClass> coarseTransferMap = MapFactoryClass::Build(Ptent->getColMap()->lib(), -1, coarseMapGidsView, Ptent->getColMap()->getIndexBase(), Ptent->getColMap()->getComm());

    // store map extractor in coarse level
    coarseLevel.Set(mapName_, coarseTransferMap, mapFact_.get());
  }
Esempio n. 22
0
void CText::Init(CViewport* pcViewport)
{
	CDrawable::Init(pcViewport);

	mcTextData.Init(GetFactory()->mpcDefaultFont);
	mfAlpha = 1.0f;
	mbCaretVisible = FALSE;
	msCaretPos.Init(0, 0);

	mpcCaret = gcUnknowns.Add<CCaret>();
	mpcCaret->Init(mpcViewport);
	AddComponent(mpcCaret);

}
Esempio n. 23
0
FdoIDirectPosition* FdoFgfCurveString::GetStartPosition() const
{
	m_streamPtr = m_data;

	// Skip over geometrytype
	FGFUTIL_SKIP_INT32S(&m_streamPtr, m_streamEnd, 1);

	// read FdoDimensionality
	FdoInt32 dimensionality = FgfUtil::ReadInt32(&m_streamPtr, m_streamEnd);
	
    FdoPtr<FdoFgfGeometryFactory> gf = GetFactory();

    // Read startPos
	return FgfUtil::ReadDirectPosition(gf, dimensionality, &m_streamPtr, m_streamEnd);
}
Esempio n. 24
0
    T & Get(const std::string& ename, const FactoryBase* factory = NoFactory::get()) {
      const FactoryBase* fac = GetFactory(ename, factory);

      if (!IsAvailable(ename, fac)) {

        TEUCHOS_TEST_FOR_EXCEPTION(needs_.NumRequests(ename, fac) < 1 && needs_.GetKeepFlag(ename, fac) == 0, Exceptions::RuntimeError,
                                   "MueLu::Level::Get(): " << ename << " has not been requested (counter = " << needs_.NumRequests(ename, fac) << ", KeepFlag = " << needs_.GetKeepFlag(ename, fac) << "). " << std::endl << "Generating factory:" << *fac << " NoFactory="<<NoFactory::get());

        fac->CallBuild(*this);
        Release(*fac);
      }

      TEUCHOS_TEST_FOR_EXCEPTION(!IsAvailable(ename, fac), Exceptions::RuntimeError, "MueLu::Level::Get(): factory did not produce expected output. " << ename << " has not been generated by " << *fac);

      return needs_.Get<T>(ename, fac);
    }
Esempio n. 25
0
/*============================================================================*/
VistaSpaceNavigator::VistaSpaceNavigator(IVistaDriverCreationMethod *crm)
	: IVistaDeviceDriver(crm)
{
	VistaDeviceSensor *pSensor = new VistaDeviceSensor;
	AddDeviceSensor( pSensor );
	pSensor->SetMeasureTranscode( GetFactory()->GetTranscoderFactoryForSensor("")->CreateTranscoder() );

	// using the USB connection we have to poll explicitly,
	// since there is no activity on the file handle, but we
	// use ioctls to make the read/write requests.
	SetUpdateType(IVistaDeviceDriver::UPDATE_EXPLICIT_POLL);
	m_pConAsp = new VistaDriverConnectionAspect;
	RegisterAspect( m_pConAsp );

	m_pConAsp->SetConnection( 0, NULL, "MAIN", true );
}
//-----------------------------------------------------------------------------
// Init, shutdown
//-----------------------------------------------------------------------------
bool CSceneViewerApp::PreInit( )
{
	if ( !BaseClass::PreInit() )
		return false;

	MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, false, false, false );

	if ( !g_pFullFileSystem || !g_pMaterialSystem || !g_pDataModel || !g_pDmElementFramework || !g_pStudioRender || !g_pDataCache || !g_pMDLCache || !g_pVGuiSurface || !g_pVGui )
	{
		Warning( "CSceneViewerApp::PreInit: Unable to connect to necessary interface!\n" );
		return false;
	}

	// initialize interfaces
	CreateInterfaceFn appFactory = GetFactory(); 
	return vgui::VGui_InitDmeInterfacesList( "SceneViewer", &appFactory, 1 );
}
  void UncoupledAggregationFactory_kokkos<LocalOrdinal, GlobalOrdinal, Node>::DeclareInput(Level& currentLevel) const {
    Input(currentLevel, "Graph");
    Input(currentLevel, "DofsPerNode");

    const ParameterList& pL = GetParameterList();

    // request special data necessary for OnePtAggregationAlgorithm
    std::string mapOnePtName = pL.get<std::string>("OnePt aggregate map name");
    if (mapOnePtName.length() > 0) {
      std::string mapOnePtFactName = pL.get<std::string>("OnePt aggregate map factory");
      if (mapOnePtFactName == "" || mapOnePtFactName == "NoFactory") {
        currentLevel.DeclareInput(mapOnePtName, NoFactory::get());
      } else {
        RCP<const FactoryBase> mapOnePtFact = GetFactory(mapOnePtFactName);
        currentLevel.DeclareInput(mapOnePtName, mapOnePtFact.get());
      }
    }
  }
    void Set(const std::string& ename, const T& entry, const FactoryBase* factory = NoFactory::get()) {
      const FactoryBase* fac = GetFactory(ename, factory);

      if (fac == NoFactory::get()) {
        // Any data set with a NoFactory gets UserData keep flag by default
        AddKeepFlag(ename, NoFactory::get(), MueLu::UserData);
      }

      // Store entry only if data have been requested (or any keep flag)
      if (IsRequested(ename, factory) || GetKeepFlag(ename, factory) != 0) {
        TEUCHOS_TEST_FOR_EXCEPTION(!IsKey(factory, ename), Exceptions::RuntimeError, "" + ename + " not found in");
        map_[factory][ename]->SetData(entry);

      } else {
        GetOStream(Warnings0) << "Level::Set: unable to store \"" << ename << "\" generated by factory " << factory
            << " on level " << toString(GetLevelID()) << ", as it has not been requested and no keep flags were set for it" << std::endl;
      }
    } // Set
Esempio n. 29
0
XLineManager::~XLineManager()
{
    const char gekqz[] = "GEKQZ";
    for(unsigned int i=0; i < sizeof(gekqz); i++)
    {
        XLineFactory* xlf = GetFactory(std::string(1, gekqz[i]));
        delete xlf;
    }

    // Delete all existing XLines
    for (XLineContainer::iterator i = lookup_lines.begin(); i != lookup_lines.end(); i++)
    {
        for (XLineLookup::iterator j = i->second.begin(); j != i->second.end(); j++)
        {
            delete j->second;
        }
    }
}
  void GenericRFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::Build(Level & fineLevel, Level & coarseLevel) const {
    FactoryMonitor m(*this, "Call prolongator factory for calculating restrictor", coarseLevel);

    RCP<const FactoryBase> PFact1 = GetFactory("P");
    if (PFact1 == Teuchos::null) { PFact1 = coarseLevel.GetFactoryManager()->GetFactory("P"); }
    RCP<PFactory> PFact = Teuchos::rcp_const_cast<PFactory>(rcp_dynamic_cast<const PFactory>(PFact1));;
    MueLu::DisableMultipleCallCheck check(PFact);

    // BuildR
    bool rmode = PFact->isRestrictionModeSet();
    PFact->setRestrictionMode(true);     // switch prolongator factory to restriction mode

    //PFact->Build(fineLevel, coarseLevel);  // call PFactory::Build explicitely
    RCP<Matrix> R = coarseLevel.Get<RCP<Matrix> >("R",PFact.get());

    PFact->setRestrictionMode(rmode);    // reset restriction mode flag

    Set(coarseLevel, "R", R);

  } //BuildR