当前位置: 首页>>代码示例>>C++>>正文


C++ Object::call方法代码示例

本文整理汇总了C++中kernel::Object::call方法的典型用法代码示例。如果您正苦于以下问题:C++ Object::call方法的具体用法?C++ Object::call怎么用?C++ Object::call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kernel::Object的用法示例。


在下文中一共展示了Object::call方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fullRigth

      void TestGuidanceControl::fullRigth()
      {
        InternalMessage("Model","Model::TestGuidanceControl::basicTest entering") ;
        /// we construct a complete system on a ship
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestGuidanceControl::basicTest")) ;

        /// should be a PhysicalWorld
        Kernel::Object* system = model->createObject() ;
        CPPUNIT_ASSERT(system->getTrait<PhysicalWorld>()) ;

        Kernel::Object* ship = system->createObject() ;
        ship->addTrait(new Positionned()) ;
        ship->addTrait(new Oriented()) ;
        ship->addTrait(new Mobile()) ;
        ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
        CPPUNIT_ASSERT(ship->getTrait<PhysicalObject>()) ;

        Kernel::Object* stick = ship->createObject() ;
        stick->addTrait(new Stick()) ;

        Kernel::Object* guidance_system = ship->createObject() ;
        guidance_system->addTrait(new GuidanceSystem(1)) ;

        Kernel::Object* guidance_control = ship->createObject() ;
        guidance_control->addTrait(new GuidanceControler()) ;

        connectStickControler(stick,guidance_control) ;
        connectControlerGuidanceSystem(guidance_control,guidance_system) ;

        // 100 on yaw means go rigth
        stick->call("Yaw",100) ;
        stick->getTrait<Stick>()->updateOrientation() ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().x == 0) ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().z == 0) ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().y < 0) ;

        stick->call("Yaw",0) ;
        stick->getTrait<Stick>()->updateOrientation() ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().x == 0) ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().z == 0) ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().y == 0) ;

        // 100 on pitch measn go down
        stick->call("Pitch",100) ;
        stick->getTrait<Stick>()->updateOrientation() ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().x < 0) ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().z == 0) ;
        CPPUNIT_ASSERT(guidance_system->getTrait<GuidanceSystem>()->NewtonMeter().y == 0) ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:49,代码来源:test_guidance_control.cpp

示例2: beamEnergy

      void TestLaser::beamEnergy()
      {
        InternalMessage("Model","Model::TestLaser::beamEnergy entering") ;
        // we construct a complete system
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestLaser::testFire")) ;
        model->init() ;

        // should be a PhysicalWorld
        Kernel::Object* system = model->createObject() ;
        CPPUNIT_ASSERT(system->getTrait<PhysicalWorld>()) ;

        Kernel::Object* ship = system->createObject() ;
        ship->addTrait(new Positionned()) ;
        ship->addTrait(new Oriented()) ;
        ship->addTrait(new Mobile()) ;
        ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship->addTrait(new Laser(Position(),Orientation(),Energy::Joule(10))) ;
        CPPUNIT_ASSERT(ship->getTrait<PhysicalObject>()) ;
        CPPUNIT_ASSERT(ship->getTrait<PhysicalWorld>()) ;

        CPPUNIT_ASSERT(system->getChildren().size()==1) ;

        InternalMessage("Model","built ship") ;

        ship->call("fire") ;

        InternalMessage("Model","fire") ;
        CPPUNIT_ASSERT(system->getDescendants<LaserBeam>().size()==1) ;
        CPPUNIT_ASSERT(system->getDescendants<Shot>().size()==1) ;

        std::set<LaserBeam*> beams = system->getDescendants<LaserBeam>() ;
        LaserBeam* beam = *(beams.begin()) ;
        
        CPPUNIT_ASSERT(beam->getEnergy().Joule()==10) ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:35,代码来源:test_laser.cpp


注:本文中的kernel::Object::call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。