4.6.6 INSを使用したFactoryFinderオブジェクト参照の取得

次のコード・スニペットは、クライアント・アプリケーションがINSを使用してFactoryFinderオブジェクトへのオブジェクト参照を取得する方法の例を示しています。完全なサンプル・コードについては、University Sampleのクライアント・アプリケーションを参照してください。

// utility to get the registrar
static UniversityW::Registrar_ptr get_registrar(
    CORBA::ORB_ptr orb
) {
    // Get the factory finder from the ORB:
    CORBA::Object_var v_fact_finder_oref =
        orb -> resolve_initial_references("FactoryFinder");
    // Narrow the factory finder :
    Tobj::FactoryFinder_var v_fact_finder_ref =
        Tobj::FactoryFinder::_narrow(v_fact_finder_oref.in());
    // Use the factory finder to find the
    // university's registrar factory :
    CORBA::Object_var v_reg_fact_oref =
        v_fact_finder_ref -> find_one_factory_by_id(
            UniversityW::_tc_RegistrarFactory -> id()
        );
    // Narrow the registrar factory :
    UniversityW::RegistrarFactory_var v_reg_fact_ref =
        UniversityW::RegistrarFactory::_narrow(
            v_reg_fact_oref.in()
        );
    // Return the university's registrar :
    return v_reg_fact_ref -> find_registrar();
}