コード例 #1
0
ファイル: settings.cpp プロジェクト: Mr-Kumar-Abhishek/qt
void snippet_locations()
{
//! [13]
    QSettings obj1("MySoft", "Star Runner");
//! [13] //! [14]
    QSettings obj2("MySoft");
    QSettings obj3(QSettings::SystemScope, "MySoft", "Star Runner");
    QSettings obj4(QSettings::SystemScope, "MySoft");
//! [14]

    {
//! [15]
    QSettings settings(QSettings::IniFormat, QSettings::UserScope,
                       "MySoft", "Star Runner");
//! [15]
    }

    {
    QSettings settings("starrunner.ini", QSettings::IniFormat);
    }

    {
    QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft",
                       QSettings::NativeFormat);
    }
}
コード例 #2
0
ファイル: amfobjecttraits.cpp プロジェクト: yufeixuan/amf-cpp
TEST(AmfObjectTraitsTest, Equality) {
	AmfObjectTraits obj1("foo", false, true);
	AmfObjectTraits obj2("foo", false, false);
	AmfObjectTraits obj3("foo", true, false);
	AmfObjectTraits obj4("foo", false, false);
	AmfObjectTraits obj5("bar", false, true);
	AmfObjectTraits obj1e("foo", false, true);

	EXPECT_NE(obj1, obj2);
	EXPECT_NE(obj1, obj3);
	EXPECT_NE(obj1, obj4);
	EXPECT_NE(obj1, obj5);
	EXPECT_EQ(obj1, obj1e);

	// Verify attributes are also compared.
	obj1.addAttribute("attr");
	EXPECT_NE(obj1, obj1e);

	obj1e.addAttribute("attr");
	EXPECT_EQ(obj1, obj1e);

	// Verify attributes can't be duplicated.
	obj1.addAttribute("attr");
	EXPECT_EQ(obj1, obj1e);
}
コード例 #3
0
ファイル: object.cpp プロジェクト: iderikon/kora
TEST(DynamicObject, Constructors) {
    kora::dynamic_t::object_t obj1;
    EXPECT_TRUE(obj1.empty());

    obj1["key"] = 5;

    kora::dynamic_t::object_t obj2(obj1);
    EXPECT_EQ(1, obj2.count("key"));
    EXPECT_EQ(5, obj2.at("key"));

    kora::dynamic_t::object_t obj3(std::move(obj2));
    EXPECT_EQ(1, obj3.count("key"));
    EXPECT_EQ(5, obj3.at("key"));

    std::map<std::string, kora::dynamic_t> map;
    map["key2"] = 6;

    kora::dynamic_t::object_t obj4(map);
    EXPECT_EQ(1, obj4.count("key2"));
    EXPECT_EQ(6, obj4.at("key2"));

    kora::dynamic_t::object_t obj5(std::move(map));
    EXPECT_EQ(1, obj5.count("key2"));
    EXPECT_EQ(6, obj5.at("key2"));

    kora::dynamic_t::object_t obj6(obj5.begin(), obj5.end());
    EXPECT_EQ(1, obj6.size());
    EXPECT_EQ(1, obj6.count("key2"));
    EXPECT_EQ(6, obj6.at("key2"));
}
コード例 #4
0
TEST_F(TesteLista, retiraEspecificoDuplo) {
	Objeto obj0(0);
	Objeto obj1(1);
	Objeto obj2(2);
	Objeto obj3(3);
	Objeto obj4(4);

	lobj.adicionaDuplo(obj0);
	lobj.adicionaDuplo(obj1);
	lobj.adicionaDuplo(obj2);
	lobj.adicionaDuplo(obj3);
	lobj.adicionaDuplo(obj4);
	ASSERT_EQ(lobj.retiraEspecificoDuplo(obj3), 3);
}
コード例 #5
0
int main () {
    Container obj1;
    obj1->Display();
    cout << "-------------------------------" <<endl;
    Container obj2(10);
    obj2->Display();
    cout << "-------------------------------" <<endl;
    Container obj3("1234");
    obj3->Display();
    cout << "-------------------------------" <<endl;
    Container obj4(10,11);
    obj4->Display();
    cout << "-------------------------------" <<endl;
}
コード例 #6
0
ファイル: class 2.cpp プロジェクト: pConst/basic_c_examples
void main(int argc, char* argv[])
{
	Coord_2d obj1(1, 1, 2005), obj2;
	int x1, y1, t;

	cout << "Size of class= " << sizeof(Coord_2d) << endl << endl;

	obj1.getcord(x1, y1, t);
	cout << "Obj1`s address is " << &obj1 << endl;
	cout << "Obj1.x`s address is " << obj1.get_x_ptr() << endl;
	cout << "obj1.x= " << x1 << endl;
	cout << "obj1.y= " << y1 << endl;
	cout << "obj1.t= " << t << endl << endl;

	obj2.getcord(x1, y1, t);
	cout << "Obj2`s address is " << &obj2 << endl;
	cout << "Obj2.x`s address is " << obj2.get_x_ptr() << endl;
	cout << "obj2.x= " << x1 << endl;
	cout << "obj2.y= " << y1 << endl;
	cout << "obj2.t= " << t << endl << endl;
	
/*Здесь вызывается конструктор копирования по умолчанию СОЗДАННЫЙ КОМПИЛЯТОРОМ.
  Создаётся ПОБИТОВАЯ копия. Это значит, что ссылки и указатели, определённые в
  исходном классе, будут указывать на те же адреса.
  Если эти ссылки должны различаться в каждом объекте,нужно писать СВОИ 
  конструкторы копирования, желательно работающие через указатель, а не ссылку.*/
	Coord_2d obj3=obj1;
	obj3.getcord(x1, y1, t);
	cout << "Obj3`s address is " << &obj3 << endl;
	cout << "Obj3.x`s address is " << obj3.get_x_ptr() << endl;
	cout << "obj3.x= " << x1 << endl;
	cout << "obj3.y= " << y1 << endl;
	cout << "obj3.t= " << t << endl << endl;

/*ИДЕАЛЬНЫЙ ВАРИАНТ. Так и нужно делать. Прелесть в том, что сам указываешь,
  КАК понимать присвоение. В частности, куда должны указывать ссылки и указатели,
  находящиеся внутри объекта.*/
	Coord_2d obj4(&obj1);
	obj3.getcord(x1, y1, t);
	cout << "Obj4`s address is " << &obj4 << endl;
	cout << "Obj4.x`s address is " << obj4.get_x_ptr() << endl;
	cout << "obj4.x= " << x1 << endl;
	cout << "obj4.y= " << y1 << endl;
	cout << "obj4.t= " << t << endl << endl;
}
コード例 #7
0
ファイル: test.cpp プロジェクト: Valeryn4/Minions
void test() {
	object_list list;
	entity obj1(list); std::cout << "OK\n";
	entity obj2(list); std::cout << "OK\n";
	entity obj3(list); std::cout << "OK\n";
	entity obj4(list); std::cout << "OK\n";
	
	npc mob1(list, 100, 200);    std::cout << "OK\n"; 

	std::cout << "Size list:" << list.return_size();
	std::cout << "\nID:" << list.return_ID(0)
		<< "\nTitle:" << list.return_title(list.return_ID(0))
		<< "\nPosition. X:" << *list.return_pos(list.return_ID(0)).x << " Y:" << *list.return_pos(list.return_ID(0)).y << std::endl;

	std::cout << "\nID:" << list.return_ID(1)
		<< "\nTitle:" << list.return_title(list.return_ID(1))
		<< "\nPosition. X:" << *list.return_pos(list.return_ID(1)).x << " Y:" << *list.return_pos(list.return_ID(1)).y << std::endl;

	std::cout << "\nID:" << list.return_ID(2)
		<< "\nTitle:" << list.return_title(list.return_ID(2))
		<< "\nPosition. X:" << *list.return_pos(list.return_ID(2)).x << " Y:" << *list.return_pos(list.return_ID(2)).y << std::endl;

	std::cout << "\nID:" << list.return_ID(3)
		<< "\nTitle:" << list.return_title(list.return_ID(3))
		<< "\nPosition. X:" << *list.return_pos(list.return_ID(3)).x << " Y:" << *list.return_pos(list.return_ID(3)).y << std::endl;

	std::cout << "\nID:" << list.return_ID(4)
		<< "\nTitle:" << list.return_title(list.return_ID(4))
		<< "\nPosition. X:" << *list.return_pos(list.return_ID(4)).x << " Y:" << *list.return_pos(list.return_ID(4)).y << std::endl;

	int trag = list.return_ID(2);
	std::cout << "\n\nPosition. X:" << *list.return_pos(list.return_ID(4)).x << " Y:" << *list.return_pos(list.return_ID(4)).y << std::endl;
	mob1.set_target(list.return_pos(list.return_ID(2)));
	bool go = true;
	mob1.move_to(go);
	std::cout << "\n\nPosition. X:" << *list.return_pos(list.return_ID(4)).x << " Y:" << *list.return_pos(list.return_ID(4)).y << std::endl;

	std::system("Pause");
}
コード例 #8
0
ファイル: main.cpp プロジェクト: OndraVoves/BackGenEngine
int main (  int argc , char **argv ) {
#if 0
    BackGenEngine::BLogger logger;
    BackGenEngine::BDynamicModuleSystem dm ( &logger );

    dm.loadModule ( "../../modules/asset/image/BImageAsset" );

#endif

#if 0
    DIR *dh;//directory handle
    struct dirent *file;//a 'directory entity' AKA file
    dh = opendir ( "./" );
    while ( file = readdir ( dh ) ) {
        printf ( "%s\n", file->d_name );
    }

    return 0;
#endif

#if 0
    BoxE::Core::BSettings s;
    s.setValue ( "a", 'a' );

    std::cout << "a: " << s.value ( "a" ).value<char>();

#endif

    BoxE::Math::BMatrix4x4f m1;
    m1.setToIdentity();
    m1.rotateX ( 90 );

    BoxE::Math::BMatrix4x4f m2 ( m1.getInverse() );

    BoxE::Math::BMatrix4x4f m3 ( m1 * m2 );


#if 0
    BackGenEngine::BLogger logger;
    BackGenEngine::BActionManager actionm;
    BackGenEngine::BDynamicModuleSystem mod_sys ( &logger );

    mod_sys.loadModule ( "../../modules/component/transformation/BTransformationComponent" );
    mod_sys.loadModule ( "../../modules/component/meshrenderer/BMeshRendererComponent" );
    mod_sys.loadModule ( "../../modules/component/cubemesh/BCubeMesh" );
    mod_sys.loadModule ( "../../modules/asset/image/BImageAsset" );
    mod_sys.loadModule ( "../../modules/asset/texture/BTextureAsset" );
    mod_sys.loadModule ( "../../modules/asset/material/BMaterialAsset" );
    mod_sys.loadModule ( "../../modules/asset_loader/image_tga/TGAloader" );
    mod_sys.loadModule ( "../../modules/asset_loader/texture/Textureloader" );
    mod_sys.loadModule ( "../../modules/asset_saver/texture/TextureSaver" );

    BSDLWindow window ( "pokus", BackGenEngine::BAbstractWindow::screen_resolution_t ( 800, 600, 0 ), 32, false, &logger );
    window.init();
    window.show();

    BOpenGLRenderer renderer ( &logger );
    renderer.init();
    renderer.onScreenChanged ( BoxE::Math::BVector3f ( 800, 600 , 0 ), false );


    BackGenEngine::BProject project ( 0, &mod_sys, &logger );
    project.setBaseDir ( "/home/backgen/pokusgame/" );

    BackGenEngine::BScene scene ( &renderer, &logger );

    BackGenEngine::BLayer *pc_layer = scene.getLayersManager().createLayer ( "vrstva1", BackGenEngine::BLayer::GUI );


    //mod_sys.loadModule ( "../../modules/component/transformation/BTransformationComponent" );
    //project.setName ( "Testing" );

    //window.show();

    BackGenEngine::BObject *pc_triangles = new BackGenEngine::BObject ( "Object1", 0 );
    BackGenEngine::BAbstractComponent *pc_transform = mod_sys.createComponent ( "Transformation", &scene );
    ( ( BTransformationComponent * ) pc_transform )->position().setXYZ ( 0.0f, 0.0f, -5.0f );
    BackGenEngine::BAbstractComponent *pc_cubemesh = mod_sys.createComponent ( "CubeMesh", &scene );
    BackGenEngine::BAbstractComponent *pc_meshrenderer = mod_sys.createComponent ( "MeshRenderer", &scene );

    pc_triangles->insertComponent ( pc_transform );
    pc_triangles->insertComponent ( pc_cubemesh );
    pc_triangles->insertComponent ( pc_meshrenderer );


    /*    PokusRenderComponent *pc_rendr_comp = new PokusRenderComponent (  &scene );
        pc_triangles->insertComponent ( pc_rendr_comp );*/
    pc_layer->insertObject ( pc_triangles );


    BackGenEngine::BButtonAction quitAction ( "Quit", BackGenEngine::BAbstractWindow::BK_ESCAPE, &window );
    actionm.insert ( &quitAction );

    BackGenEngine::BActionManager::actions_hash_t::ConstIterator iter = actionm.constBegin();


    /*    BoxE::Math::BMatrix4x4f ortho;
        ortho.setOrthographic ( 0, 800, 0, 600, 0.0f, 1.0f );

        renderer.pushMatrix ( BOpenGLRenderer::MT_PROJECTION );
        renderer.setMatrix ( BOpenGLRenderer::MT_PROJECTION, ortho );*/


    BackGenEngine::BObject *pc_camera_object = new BackGenEngine::BObject ( "Camera", 0 );
    BBaseCameraComponent *pc_camera_component = new BBaseCameraComponent ( &scene );
    pc_camera_component->resize ( 800, 600 );
    pc_camera_component->insertLayer ( pc_layer );


    /*    glViewport ( 0, 0, 800, 600 );
        glMatrixMode ( GL_PROJECTION );
        glLoadIdentity();
        glOrtho ( 0, 800, 0, 600, -1, 1 );*/

    BImageAsset *pc_image = ( BImageAsset * ) mod_sys.createAsset ( "Image", &project, &renderer, &project.getAssetManager(), &logger );
    pc_image->setName ( "image1" );
    pc_image->setPath ( "skin.tga" );
    pc_image->use();

    BTextureAsset *pc_texture = ( BTextureAsset * ) mod_sys.createAsset ( "Texture", &project, &renderer, &project.getAssetManager(), &logger  );
    pc_texture->setImage ( pc_image );
    pc_texture->setMipmaping ( true );
    //pc_texture->setPath( "texture1.texture" );

    BMaterialAsset *pc_material = ( BMaterialAsset * ) mod_sys.createAsset ( "Material", &project, &renderer, &project.getAssetManager(), &logger  );
    pc_material->setTextureUnit ( 0, pc_texture );

    ( ( BMeshRendererComponent * ) pc_meshrenderer )->setMaterialAsset ( pc_material );
    ( ( BMeshRendererComponent * ) pc_meshrenderer )->setTiling ( BoxE::Math::BVector2f ( 2.0f, 2.0f ) );


    float i = 0;
    BoxE::Math::BMatrix4x4f rot;
    while ( !window.update() && quitAction.isUp() ) {
        i += 1;
        ( ( BTransformationComponent * ) pc_transform )->rotation().y ( i );

        pc_camera_component->render();

        renderer.beginRender ( true, true, BoxE::Math::BVector3f ( 0.0f, 0.0f, 0.0f ) );
        renderer.drawSreenTexture ( pc_camera_component->getOutputTexture() );
        //renderer.drawSreenTexture ( pc_texture->getTexture() );
        renderer.endRender();

        SDL_GL_SwapBuffers( );

//      renderer.popMatrix ( BOpenGLRenderer::MT_PROJECTION );
//renderer.popMatrix ( BOpenGLRenderer::MT_WORLD );
    };
#endif
    //BoxE::Math::BMatrix4x4f matrix( BoxE::Math::BMatrix4x4f::IDENTITY );

#if 0

    BackGenEngine::BObject obj1 ( "obj1" );
    BackGenEngine::BObject obj2 ( "obj2", &obj1 );
    BackGenEngine::BObject obj3 ( "obj3" );
    BackGenEngine::BObject obj4 ( "obj4", &obj1 );

    BackGenEngine::BObject::objects_list_t::ConstIterator it = obj1.constObjectsBegin();
    while ( it != obj1.constObjectsEnd() ) {
        std::cout << ( *it )->name() << std::endl;
        ++it;
    }


    obj1.name ( "OBJ1" );

    BackGenEngine::BLayersManager lm;

    BackGenEngine::BLayer layer1 ( "layer", BackGenEngine::BLayer::NORMAL );
    layer1.insertObject ( &obj1 );



    BackGenEngine::BLayer *layer2 = lm.createLayer ( "layer1", BackGenEngine::BLayer::NORMAL );

    if ( lm.removeLayer ( "layer1" ) ) {
        std::cout << obj1.layer()->name() << std::endl;
    }

    BackGenEngine::BTagsManager tm;
    BackGenEngine::BTag *tag1 = tm.createTag ( "tag1" );
    BackGenEngine::BTag *tag2 = tm.createTag ( "tag1" );

    tm.removeTag ( tag1 );

    if ( tm.containTag ( "tag1" ) ) {
        std::cout << "obsahuje" << std::endl;
    }

#endif

#if 0
    BackGenEngine::BLogger logger;
    BackGenEngine::BActionManager actionm;
    BSDLWindow window ( "TestApp", BackGenEngine::BAbstractWindow::screen_resolution_t ( 800, 600, 0 ), 32, false, &logger );
    window.init();
    window.show();

    window.onKeyDown().connect ( &on_key_down );
    window.onMouseMotion().connect ( &mouse );

    BackGenEngine::BButtonAction quitAction ( "Quit", BackGenEngine::BAbstractWindow::BK_ESCAPE, &window );
    actionm.insert ( &quitAction );

    BackGenEngine::BActionManager::actions_hash_t::ConstIterator iter = actionm.constBegin();

    while ( !window.update() && quitAction.isUp() ) {
    };

#endif

#if 0
    BoxE::Core::BLibrary SDL ( "SDL" );
    if ( !SDL.load() ) {
        std::cout << "ERROR: " << SDL.errorString().constData() << std::endl;
    }

    void *a = SDL.resolv ( "SDL_Init" );
    if ( !a ) {
        std::cout << "ERROR: " << SDL.errorString().constData() << std::endl;
    }
    //void* a = BoxE::Core::BLibrary::resolve( "/usr/lib/libSDL.so", "SDL_Init" );
#endif

#if 0

    BoxE::Core::BFile out2;
    out2.setFilename ( "a.txt" );
//  out2.open(BoxE::Core::BIODevice::WriteOnly);

    BoxE::Core::BTextStream stream ( &out2 );

//  stream << "1";

    out2.close();
    out2.open ( BoxE::Core::BIODevice::ReadOnly );

    std::cout << stream.readAll().constData() << std::endl;

#endif

    return 0;
}
コード例 #9
0
ファイル: main.cpp プロジェクト: drthomas21/CS332C
int main() {
	srand(static_cast<unsigned int>(time(NULL)));
	std::vector<int> set1(10,0);
	set1[9] = 31;
	set1[8] = 30;
	set1[7] = 24;
	set1[6] = 15;
	set1[5] = 13;
	set1[4] = 10;
	set1[3] = 9;
	set1[2] = 5;
	set1[1] = 4;
	set1[0] = 2;
	MySet obj1(set1);

	std::cout << "Set 1: " << obj1 << std::endl << std::endl;

	//Insert
	for (int i = 0; i < 20; i++) {
		int randNum = rand() % 1000;
		std::cout << "Lets insert " << randNum << " into the set";
		obj1.insert(randNum);
		std::cout << obj1 << std::endl << std::endl;
	}

	//Remove
	for (int i = 0; i < 20; i++) {
		int randNum = rand() % 20;
		std::cout << "Lets remove " << randNum << " into the set";
		obj1.remove(randNum);
		std::cout << obj1 << std::endl << std::endl;
	}

	std::cout << std::endl << std::endl;
	

	//New Set
	std::vector<int> set2(30,0);
	for (int i = 0; i < set2.size(); i++) {
		set2[i] = rand() % 1000;
	}
	MySet obj2(set2);
	std::cout << "Set 2: " << obj2 << std::endl;

	std::vector<int> set3(30, 0);
	for (int i = 0; i < set3.size(); i++) {
		set3[i] = rand() % 1000;
	}
	MySet obj3(set3);
	std::cout << "Set 3: " << obj3 << std::endl;

	//Add
	std::cout << "Set 3 + Set 2: ";
	std::cout << (obj3 + obj2) << std::endl << std::endl;

	//Sub
	std::cout << "Set 3 - Set 2: ";
	std::cout << (obj3 - obj2) << std::endl << std::endl;

	//Intersect
	std::cout << "Set 3 & Set 2: ";
	std::cout << (obj3 & obj2) << std::endl << std::endl;

	//Equals
	std::cout << "Set 3 == Set 2: ";
	std::cout << (obj3 == obj2 ? "Yes" : "No") << std::endl << std::endl << std::endl;

	//New Set
	std::vector<int> set4(30, 0);
	for (int i = 0; i < set4.size(); i++) {
		set4[i] = rand() % 1000;
	}
	MySet obj4(set4);
	std::cout << "Set 4: " << obj4 << std::endl;

	MySet obj5(set4);
	std::cout << "Set 5: " << obj5 << std::endl;

	//Equals
	std::cout << "Set 4 == Set 5: ";
	std::cout << (obj4 == obj5 ? "Yes" : "No") << std::endl;

	return 0;
}
コード例 #10
0
ファイル: application.cpp プロジェクト: vinther/quaketastic
    int run() {
        if (!initialize()) {
            return 1;
        }

        app_scene.initialize();

        qts::resource_cache<qts::mesh_loader> mesh_cache;
        qts::static_object obj1("models/cow-nonormals.obj", mesh_cache);
        qts::static_object obj2("models/sponza.obj", mesh_cache);
        qts::static_object obj3("models/cow-nonormals.obj", mesh_cache);
        qts::static_object obj4("models/ladybird.obj", mesh_cache);

        obj1.transform = glm::translate(obj1.transform, glm::vec3(-100.0f, 0.0f, 0.0f));
        obj3.transform = glm::translate(obj3.transform, glm::vec3( 100.0f, 500.0f, 0.0f));

        qts::resource_cache<qts::bsp_map_loader> bsp_map_cache;
        bsp_map_cache.get_resource("maps/q3ctf1.bsp");

        app_scene.append(obj1);
        app_scene.append(obj2);
        app_scene.append(obj3);
        app_scene.append(obj4);

        uint64_t frame_id = 0;
        int key, action, type;
        int mouse_x, mouse_y;
        decltype(keybindings)::const_iterator keybinding_iter;

        while (glfwGetWindowParam(GLFW_OPENED) && ++frame_id) {
            glfwSwapBuffers();

            while (0 < input_events.size()) {
                std::tie(key, action, type) = input_events.front();

                keybinding_iter = keybindings.find(std::make_tuple(key, action, type));

                if (std::end(keybindings) != keybinding_iter) {
                    keybinding_iter->second(game_state);
                }

                if (GLFW_PRESS == action) {
                    active_keys.insert(key);
                } else if (GLFW_RELEASE == action) {
                    active_keys.erase(key);
                }

                input_events.pop();
            }

            if (game_state.quit_requested) {
                glfwCloseWindow();
            }

            if (qts::game_state::mouse_mode::LOCKED == game_state.current_mouse_mode) {
                int current_mouse_x, current_mouse_y;
                int dx, dy;
                auto& rotation = game_state.active_camera->rotation;

                glfwGetMousePos(&current_mouse_x, &current_mouse_y);

                dx = (current_mouse_x - mouse_x);
                dy = (current_mouse_y - mouse_y);

                rotation = rotation * (glm::quat(1.0f, glm::vec3(dy * 0.000f, dx * 0.001f, 0.0f)));
                rotation = (glm::quat(1.0f, glm::vec3(dy * 0.001f, dx * 0.000f, 0.0f))) * rotation;
                rotation = glm::normalize(rotation);

                mouse_x = current_mouse_x;
                mouse_y = current_mouse_y;
            }

            for (auto& kp: game_state.active_effects) {
                kp.second(game_state);
            }

            app_scene.render(*game_state.active_camera);

            std::this_thread::sleep_for(std::chrono::milliseconds(1));
        }

        return 0;
    }