示例#1
0
void save( Archive& archive, int mode, const char* name, boost::scoped_ptr<Type>& object )
{
    SWEET_ASSERT( mode == MODE_VALUE );

    ObjectGuard<Archive> guard( archive, name, object.get(), mode, object.get() != 0 ? 1: 0 );
    if ( object.get() )
    {
        archive.persist( SWEET_TYPEID(*object.get()), archive, object.get() );
    }
}
示例#2
0
void HeartbeatArrival(uint16_t sourceId, const std::uint8_t *data, std::uint8_t len)
{
	if (len<5)
		return;
	CANExtended::DeviceState state = static_cast<CANExtended::DeviceState>(data[0]);
	if (state != CANExtended::Operational)
		return;
	auto unit = unitManager->FindUnit(sourceId&0x7f);
	bool updated = (unit!=nullptr) && (unit->UpdateStatus()==StorageUnit::Updated);
	
	if (unit == nullptr || updated)
	{
		StorageBasic basic(CanEx);
		basic.DeviceId = sourceId;
		basic.SensorNum = data[2];
		basic.Version = (data[3]<<8)|data[4];
		switch (data[1])
		{
			case UNIT_TYPE_INDEPENDENT:
				unit.reset(new IndependentUnit(basic));
				break;
			case UNIT_TYPE_UNITY:
				unit.reset(new UnityUnit(basic));
				break;
			case UNIT_TYPE_UNITY_RFID:
				unit.reset(new RfidUnit(basic));
				break;
			default:
				CanEx->Sync(sourceId, DeviceSync::SyncLive,  CANExtended::Trigger);
				return;
		}
		unit->ReadCommandResponse.bind(ethEngine.get(), &NetworkEngine::DeviceReadResponse);
		unit->WriteCommandResponse.bind(ethEngine.get(), &NetworkEngine::DeviceWriteResponse);
		CanEx->RegisterDevice(unit);
		if (updated)
		{	
			unitManager->Recover(sourceId&0x7f, unit);
#ifdef DEBUG_PRINT
			cout<<"#Recovered Device 0x"<<std::hex<<sourceId<<std::dec<<endl;
#endif
		}
		else
		{
			unitManager->Add(sourceId&0x7f, unit);
#ifdef DEBUG_PRINT
			cout<<"#Added Device 0x"<<std::hex<<sourceId<<std::dec<<endl;
#endif
		}
	}
	//CanEx->Sync(sourceId, DeviceSync::SyncLive, CANExtended::AutoSync); //Confirm & Start AutoSync
	CanEx->Sync(sourceId, DeviceSync::SyncLive, CANExtended::Trigger);
	if (updated)
		unitManager->SyncUpdate();
}
示例#3
0
void resolve( Archive& archive, int mode, boost::scoped_ptr<Type>& object )
{
    SWEET_ASSERT( mode == MODE_VALUE );

    ObjectGuard<Archive> guard( archive, 0, object.get(), MODE_VALUE );
    if ( object.get() != NULL )
    {
        archive.track( object.get(), &object );
        archive.persist( SWEET_TYPEID(*object.get()), archive, object.get() );
    }
}
示例#4
0
void BlinkDetector::update(const boost::scoped_ptr<IplImage> &eyeFloat) {
	if (!_initialized) {
		cvCopy(eyeFloat.get(), _averageEye.get());
		_initialized = true;
	}

	double distance = cvNorm(eyeFloat.get(), _averageEye.get(), CV_L2);
	_accumulator.update(distance);
	//cout << "update distance" << distance << " -> " << accumulator.getValue() << endl;
	_states.updateState(distance / _accumulator.getValue());
	cvRunningAvg(eyeFloat.get(), _averageEye.get(), 0.05);
}
void InputEventsWestonTest::SetUp()
{
  WestonTest::SetUp();
  
  clientLibrary.Load();
  eglLibrary.Load();
  xkbCommonLibrary.Load();
  
  xkbContext.reset(CXKBKeymap::CreateXKBContext(xkbCommonLibrary),
                   boost::bind(&IDllXKBCommon::xkb_context_unref,
                               &xkbCommonLibrary, _1));
  keymap.reset(new CXKBKeymap(
                 xkbCommonLibrary, 
                 CXKBKeymap::CreateXKBKeymapFromNames(xkbCommonLibrary,
                                                      xkbContext.get(),
                                                      "evdev",
                                                      "pc105",
                                                      "us",
                                                      "",
                                                      "")));
  
  display.reset(new xw::Display(clientLibrary));
  queue.reset(CreateEventQueue());
  registry.reset(new xw::Registry(clientLibrary,
                                  display->GetWlDisplay(),
                                  *this));
  loop.reset(new xwe::Loop(listener, *queue));

  /* Wait for the seat, shell, compositor to appear */
  WaitForSynchronize();
  
  ASSERT_TRUE(input.get() != NULL);
  ASSERT_TRUE(compositor.get() != NULL);
  ASSERT_TRUE(shell.get() != NULL);
  ASSERT_TRUE(xbmcWayland.get() != NULL);
  
  /* Wait for input devices to appear etc */
  WaitForSynchronize();
  
  surface.reset(new xw::Surface(clientLibrary,
                                compositor->CreateSurface()));
  shellSurface.reset(new xw::ShellSurface(clientLibrary,
                                          shell->CreateShellSurface(
                                            surface->GetWlSurface())));
  openGLSurface.reset(new xw::OpenGLSurface(eglLibrary,
                                            surface->GetWlSurface(),
                                            SurfaceWidth,
                                            SurfaceHeight));

  wl_shell_surface_set_toplevel(shellSurface->GetWlShellSurface());
  surface->Commit();
}
    boost::shared_ptr<mongo::DBClientCursor> query(const std::string &json, int limit = 0, int skip = 0) {
        try {
            mongo::DBClientCursor *ptr = conn_->get()->query(ns_, mongo::Query(json), limit, skip).release();

            if (!ptr)
                throw conn_->get()->getLastError();

            return boost::shared_ptr<mongo::DBClientCursor>(ptr);
        } catch(mongo::DBException &de) {
            std::string err_msg = "Mongodb Plugin: ";
            err_msg += de.toString();
            err_msg += "\n";
            throw mapnik::datasource_exception(err_msg);
        }
    }
示例#7
0
void
Sound_as::setVolume(int volume)
{
    // TODO: check what takes precedence in case we
    //       have both an attached DisplayObject *and*
    //       some other sound...
    //
    if ( _attachedCharacter ) {
        DisplayObject* ch = _attachedCharacter->get();
        if ( ! ch ) {
            log_debug("Character attached to Sound was unloaded and "
                      "couldn't rebind");
            return;
        }
        ch->setVolume(volume);
        return;
    }

    // If we're not attached to a DisplayObject we'll need to use
    // sound_handler for volume. If we have no sound handler, we
    // can't do much, so we'll just return
    if (!_soundHandler) {
        return;
    }

    // Now, we may be controlling a specific sound or
    // the final output as a whole.
    // If soundId is -1 we're controlling as a whole
    //
    if ( soundId == -1 ) {
        _soundHandler->setFinalVolume(volume);
    } else {
        _soundHandler->set_volume(soundId, volume);
    }
}
示例#8
0
 static
 Recorder* GetInstance() {
   if (!instance) {
     instance.reset(new ASRASPRecorder);
   }
   return instance.get();
 }
示例#9
0
// run on just the target CPU
void testAffinity2(boost::scoped_ptr<TestPeriodic>& run,
                   boost::scoped_ptr<Activity>& t,
                   int targetCPU)
{
    bool r = false;

    t->run( run.get() );

    BOOST_CHECK(t->setCpuAffinity(1 << targetCPU));
    BOOST_CHECK_EQUAL((1 << targetCPU), t->getCpuAffinity());

    if ( t->getScheduler() == os::HighestPriority) {
        r = t->start();
        BOOST_CHECK_MESSAGE( r, "Failed to start Thread");
        r = t->stop();
        BOOST_CHECK_MESSAGE( r, "Failed to stop Thread");
        BOOST_CHECK_MESSAGE( run->stepped == true, "Step not executed" );
        BOOST_CHECK_EQUAL(targetCPU, run->cpu);
        BOOST_CHECK_LT(0, run->succ);
        run->reset();
    }
    BOOST_CHECK_EQUAL(0, run->cpu);
    r = t->start();
    BOOST_CHECK_MESSAGE( r, "Failed to start Thread");
    sleep(1);
    r = t->stop();
    BOOST_CHECK_MESSAGE( r, "Failed to stop Thread" );
    BOOST_CHECK_MESSAGE( run->stepped == true, "Step not executed" );
    BOOST_CHECK_EQUAL(targetCPU, run->cpu);
    BOOST_CHECK_LT(0, run->succ);

    t->run(0);
}
示例#10
0
文件: tree.hpp 项目: qnzhou/cgal
    float similarity_path(float const* sample_1, float const* sample_2) {
        NodeT const* node_1 = root_node.get();
        NodeT const* node_2 = root_node.get();
        int n_common = 0;
        int n_1 = 1;
        int n_2 = 1;

        while (node_1 == node_2) {
            if (node_1->is_leaf) {
                return 1;
            }
            n_common++;
            node_1 = node_1->split(sample_1);
            node_2 = node_2->split(sample_2);
        }
        while (!node_1->is_leaf) {
            node_1 = node_1->split(sample_1);
            n_1++;
        }
        while (!node_2->is_leaf) {
            node_2 = node_2->split(sample_2);
            n_2++;
        }
        return n_common/sqrt((n_common + n_1)*(n_common + n_2));
    }
示例#11
0
/*! \return pointer to unique global handle for the CUDA simulator plugin */
const Plugin*
cudaPlugin()
{
	if(!libcuda) {
		libcuda.reset(new Plugin("nemo_cuda"));
	}
	return libcuda.get();
}
示例#12
0
void load( Archive& archive, int mode, const char* name, boost::scoped_ptr<Type>& object )
{
    SWEET_ASSERT( object.get() == NULL );
    SWEET_ASSERT( mode == MODE_VALUE );

    ObjectGuard<Archive> guard( archive, name, 0, MODE_VALUE );
    object.reset( static_cast<Type*>(archive.create_and_persist<Type>()) );
}
示例#13
0
 void save(
     Archive & ar, 
     const boost::scoped_ptr< T > & t, 
     const unsigned int /* version */
 ){
     T* r = t.get();
     ar << boost::serialization::make_nvp("scoped_ptr", r);
 }
示例#14
0
 ///Delivers pointer to wordmap
 bool run ( Data& d ) {
   if (wm_ != NULL ) {
     LINFO ( "wordmap available in data object under key=" << key_ );
     d.wm[key_] = wm_.get();
   } else {
     LINFO ( "Wordmap available");
   }
   return false;
 };
示例#15
0
TranslatorRoster*
TranslatorRoster::default_roster()
{
	static boost::scoped_ptr<TranslatorRoster> roster;
	if(! roster)
		roster.reset(new TranslatorRoster);

	return roster.get();
}
std::vector<std::vector<double>>
  ribi::ImageCanvas::ConvertToGreyYx(const std::string& filename) noexcept
{
  const boost::scoped_ptr<QImage> qimage{
    new QImage(filename.c_str())
  };
  assert(qimage);
  return ConvertToGreyYx(qimage.get());
}
示例#17
0
void SongLoaderTest::LoadLocalDirectory(const QString &filename) {
  // Load the directory
  SongLoader::Result ret = loader_->Load(QUrl::fromLocalFile(filename));
  ASSERT_EQ(SongLoader::WillLoadAsync, ret);

  QSignalSpy spy(loader_.get(), SIGNAL(LoadFinished(bool)));

  // Start an event loop to wait for it to read the directory
  QEventLoop loop;
  QObject::connect(loader_.get(), SIGNAL(LoadFinished(bool)),
                   &loop, SLOT(quit()));
  loop.exec(QEventLoop::ExcludeUserInputEvents);
  loader_.get()->EffectiveSongsLoad();

  // Check the signal was emitted with Success
  ASSERT_EQ(1, spy.count());
  EXPECT_EQ(true, spy[0][0].toBool());

  // Check it loaded three files
  ASSERT_EQ(3, loader_->songs().count());
  EXPECT_EQ("Beep mp3", loader_->songs()[2].title());
}
示例#18
0
文件: tree.hpp 项目: qnzhou/cgal
 float const* evaluate(FeatureType const* sample) {
     // start with root
     NodeT const* node = root_node.get();
     // split until leaf
     while (node && !node->is_leaf) {
         node = node->split(sample);
     }
     if (!node) {
         // bug if this is reached
         return 0;
     } else {
         return node->votes();
     }
 }
示例#19
0
int main()
{
	HAL_MspInit();
#ifdef DEBUG_PRINT	
	cout<<"System Started..."<<endl;
#endif	
	SerializableObjects::CommStructures::Register();
	
	ispUpdater.reset(new ISPProgram(Driver_USART1));
	ethConfig.reset(new NetworkConfig(Driver_USART3));
	unitManager.reset(new UnitManager(Driver_USART3, ispUpdater));
	
	//Ethernet Init
	net_initialize();
//	osDelay(100);
//	Driver_ETH_PHY0.SetMode(ARM_ETH_PHY_AUTO_NEGOTIATE);
	
	ethEngine.reset(new NetworkEngine(ethConfig->GetIpConfig(IpConfigGetServiceEnpoint), unitManager));
	ethConfig->ServiceEndpointChangedEvent.bind(ethEngine.get(),&NetworkEngine::ChangeServiceEndpoint);
	
#ifdef DEBUG_PRINT
	cout<<"Ethernet Initialized"<<endl;
#endif
	
	//Initialize CAN
	CanEx.reset(new CANExtended::CanEx(Driver_CAN1, CANEX_HOST));
	CanEx->HeartbeatArrivalEvent.bind(&HeartbeatArrival);
#ifdef DEBUG_PRINT
	cout<<"CANBus Initialized"<<endl;
#endif
	
	osTimerId heartbeat = osTimerCreate(osTimer(HeatbeatTimer), osTimerPeriodic, NULL);
	osTimerStart(heartbeat, 500);
	
	osThreadCreate(osThread(CanPollWorker), NULL);
	osThreadCreate(osThread(Traversal), NULL);
	
	//Start collecting all devices
	CanEx->SyncAll(DeviceSync::SyncLive, CANExtended::Trigger);
	
	osThreadCreate(osThread(SyncDataLauncher), NULL);
	
	while (1)
	{
		net_main();
		ethEngine->Process();
		osThreadYield();
	}
}
示例#20
0
	virtual void setup( const OFX::RenderArguments& args )
	{
		// destination view
		_dst.reset( _clipDst->fetchImage( args.time ) );
		if( !_dst.get() )
			BOOST_THROW_EXCEPTION( exception::ImageNotReady() );
		if( _dst->getRowBytes() == 0 )
			BOOST_THROW_EXCEPTION( exception::WrongRowBytes() );
		//		_dstPixelRod = _dst->getRegionOfDefinition(); // bug in nuke, returns bounds
		_dstPixelRod       = _clipDst->getPixelRod( args.time, args.renderScale );
		_dstPixelRodSize.x = ( this->_dstPixelRod.x2 - this->_dstPixelRod.x1 );
		_dstPixelRodSize.y = ( this->_dstPixelRod.y2 - this->_dstPixelRod.y1 );
		_dstView           = getView( _dst.get(), _dstPixelRod );

		#ifndef TUTTLE_PRODUCTION
		// init dst buffer with red to highlight uninitialized pixels
		const OfxRectI dstBounds = this->translateRoWToOutputClipCoordinates( _dst->getBounds() );
		View dstToFill           = boost::gil::subimage_view( _dstView,
		                                                      dstBounds.x1, dstBounds.y1,
		                                                      dstBounds.x2 - dstBounds.x1, dstBounds.y2 - dstBounds.y1 );
		const boost::gil::rgba32f_pixel_t errorColor( 1.0, 0.0, 0.0, 1.0 );
		fill_pixels( dstToFill, errorColor );
		#endif
	}
示例#21
0
文件: tree.hpp 项目: qnzhou/cgal
 float similarity_endnode(float const* sample_1, float const* sample_2) {
     NodeT const* node_1 = root_node.get();
     NodeT const* node_2 = root_node.get();
     while (!node_1->is_leaf) {
         node_1 = node_1->split(sample_1);
     }
     while (!node_2->is_leaf) {
         node_2 = node_2->split(sample_2);
     }
     if (node_1 == node_2) {
         return 1.0;
     } else {
         return 0.0;
     }
 }
示例#22
0
	virtual void setup( const OFX::RenderArguments& args )
	{
		// destination view
//		TUTTLE_COUT_INFOS;
//		TUTTLE_COUT_VAR( "dst - fetchImage " << time );
		_dst.reset( _clipDst->fetchImage( args.time ) );
		if( !_dst.get() )
			BOOST_THROW_EXCEPTION( exception::ImageNotReady()
				<< exception::dev() + "Error on clip " + quotes(_clipDst->name()) );
		if( _dst->getRowDistanceBytes() == 0 )
			BOOST_THROW_EXCEPTION( exception::WrongRowBytes()
				<< exception::dev() + "Error on clip " + quotes(_clipDst->name()) );
		
		//		_dstPixelRod = _dst->getRegionOfDefinition(); // bug in nuke, returns bounds
		_dstPixelRod       = _clipDst->getPixelRod( args.time, args.renderScale );
		_dstPixelRodSize.x = ( this->_dstPixelRod.x2 - this->_dstPixelRod.x1 );
		_dstPixelRodSize.y = ( this->_dstPixelRod.y2 - this->_dstPixelRod.y1 );
	}
示例#23
0
	void SetUp() {
		empty_hcat.reset(new HCat());
		empty_hcat->measure();

		single_col_hcat.reset(new HCat());
		single_col_hcat->add(Text::create("abc\nde"));
		single_col_hcat->measure();

		same_height_hcat.reset(new HCat());
		same_height_hcat->add(Text::create("abc\nde"));
		same_height_hcat->add(Text::create("g\nhi"));
		same_height_hcat->add(Text::create("jklm\nop"));
		same_height_hcat->measure();

		different_height_hcat.reset(new HCat());
		different_height_hcat->add(Text::create("abcde"));
		different_height_hcat->add(Text::create("g\nhi\nxy"));
		different_height_hcat->add(Text::create("jklm\nop"));
		different_height_hcat->add(Text::create("JKLM\nOP"));
		different_height_hcat->measure();

		nested_hcat.reset(new HCat());
		nested_hcat->add(new Text("a"));
		nested_hcat->add(new HCat(*different_height_hcat));
		nested_hcat->add(new HCat(*same_height_hcat));
		nested_hcat->measure();

		with_empty_cols_hcat.reset(new HCat());
		with_empty_cols_hcat->add(new Empty());
		with_empty_cols_hcat->add(new Text("g"));
		with_empty_cols_hcat->add(new Empty());
		with_empty_cols_hcat->measure();

		only_empty_cols_hcat.reset(new HCat());
		only_empty_cols_hcat->add(new Empty());
		only_empty_cols_hcat->add(new Empty());
		only_empty_cols_hcat->measure();

		empty            = empty_hcat.get();
		single_col       = single_col_hcat.get();
		same_height      = same_height_hcat.get();
		different_height = different_height_hcat.get();
		nested           = nested_hcat.get();
		with_empty_cols  = with_empty_cols_hcat.get();
		only_empty_cols  = only_empty_cols_hcat.get();
	}
示例#24
0
bool
Sound_as::getVolume(int& volume)
{
    // TODO: check what takes precedence in case we
    //       have both an attached DisplayObject *and*
    //       some other sound...
    //
    if ( _attachedCharacter ) {
        //log_debug("Sound has an attached DisplayObject");
        DisplayObject* ch = _attachedCharacter->get();
        if (! ch) {
            log_debug("Character attached to Sound was unloaded and "
                        "couldn't rebind");
            return false;
        }
        volume = ch->getVolume();
        return true;
    }

    // If we're not attached to a DisplayObject we'll need to query
    // sound_handler for volume. If we have no sound handler, we
    // can't do much, so we'll return false
    if (!_soundHandler) {
        log_debug("We have no sound handler here...");
        return false;
    }

    // Now, we may be controlling a specific sound or
    // the final output as a whole.
    // If soundId is -1 we're controlling as a whole
    //
    if (soundId == -1) {
        volume = _soundHandler->getFinalVolume();
    } else {
        volume = _soundHandler->get_volume(soundId);
    }

    return true;
}
示例#25
0
    virtual void setup(const OFX::RenderArguments& args)
    {
        ImageProcessor::setup(args);

        // source view
        _src.reset(_clipSrc->fetchImage(args.time));
        if(!_src.get())
            BOOST_THROW_EXCEPTION(exception::ImageNotReady()
                                  << exception::dev() + "Error on clip " + quotes(_clipSrc->name()));
        if(_src->getRowDistanceBytes() == 0)
            BOOST_THROW_EXCEPTION(exception::WrongRowBytes()
                                  << exception::dev() + "Error on clip " + quotes(_clipSrc->name()));

        if(OFX::getImageEffectHostDescription()->hostName == "uk.co.thefoundry.nuke")
        {
            // bug in nuke, getRegionOfDefinition() on OFX::Image returns bounds
            _srcPixelRod = _clipSrc->getPixelRod(args.time, args.renderScale);
        }
        else
        {
            _srcPixelRod = _src->getRegionOfDefinition();
        }
    }
示例#26
0
	const geo::IntersectionInfo intersect( const geo::HalfLine& line ) const {
		if(shape_.get()!=0) {
			return shape_->intersect(line);
		}
		return geo::no_intersection;
	}
inline void debug_print_val_deterministically(boost::scoped_ptr<T> const& p) {
  debug_print_ptr_deterministically(p.get());
}
示例#28
0
	OfxhPluginHandle*       getPluginHandle()       { return _pluginHandle.get(); }
示例#29
0
文件: FindBSA.cpp 项目: npge/npge
    BOOST_FOREACH (std::string seq_group, seq_groups) {
        SequencePtr seq = name2seq[seq_group];
        if (seq) {
            rows[seq.get()] = BSRow();
        } else {
            BOOST_FOREACH (SequencePtr seq, bs.seqs()) {
                if (seq->genome() == seq_group ||
                        seq->chromosome() == seq_group ||
                        seq_group == "all") {
                    rows[seq.get()] = BSRow();
                }
            }
        }
    }
    bsa_make_rows(rows, *block_set());
    boost::scoped_ptr<TreeNode> tree((bsa_make_tree(rows)));
    BSA& aln = block_set()->bsa(name);
    int genomes = genomes_number(*block_set());
    bsa_make_aln_by_tree(aln, rows, tree.get(), genomes);
    bsa_orient(aln);
    bsa_move_fragments(aln);
    bsa_remove_pure_gaps(aln);
}

const char* FindBSA::name_impl() const {
    return "Build blockset alignment";
}

}

示例#30
0
 inline Kernel* KernelModel::getKernel()
 { return mKernel.get();  }