示例#1
0
 void initialize (const Daisy& daisy, const Scope& scope, Treelog& msg)
 { 
   if (action.get ())
     action->initialize (daisy, scope, msg); 
 }
示例#2
0
	pm::Pmd * get_pmd() { return pmd.get(); }
示例#3
0
 COCA_API IClock& getClock()
 {
     if ( !_clock.get() ) { _clock.reset( new Clock() ); }
     return *_clock;
 }
示例#4
0
    Test()
    {
        Utility::Scene scene;
        scene.Load(L"simple_house.pmd");
        m_static_mesh.reset(scene.CookStaticMesh(L"Cube"));
        System::Buffer buffer;
        m_static_mesh->Save(buffer);
        System::BinaryFile::Save(System::Environment::Instance()->GetModelFolder() + L"simple_house.mesh", buffer);

        x = y = z = 10;
        m_driver.Start(System::Window::Instance());
        m_driver.SetClearColor(0.7, 0.6, 0, 1);

        m_static_vao.reset(new OpenGL::StaticObject());
        m_static_vao->SetStaticObject(m_static_mesh.get());
        m_static_vao->Init();

        m_quad.reset(new OpenGL::QuadObject());
        m_quad->Init();

        m_grid.reset(new OpenGL::GridObject());
        m_grid->SetWidth(1);
        m_grid->SetHeight(1);
        m_grid->SetHeightSlice(16);
        m_grid->SetWidthSlice(16);
        m_grid->Init();/**/

        m_image = ImageModule::Importer().LoadRGB(System::Environment::Instance()->GetTextureFolder() + L"diffuse_map2.png");
        m_gray_image = ImageModule::Importer().LoadRGB(System::Environment::Instance()->GetTextureFolder() + L"house_normal2.png");
        m_height_map.reset(new OpenGL::Texture2D(m_gray_image));
        m_texture.reset(new OpenGL::Texture2D(m_image));

        //m_texture.reset(new OpenGL::Texture2D(m_image));
        //m_texture_context.reset(new OpenGL::TextureContext());
        //m_texture_context->SetTexture0(m_texture.release());
        //m_texture_context->SetTexture1(m_height_map.release());
        //	m_camera.SetPositionAndDirection(Math::vec3(0,1.8, 0), Math::vec3(0, 0, 1), Math::vec3(0,1,0));
        //	m_camera.SetProperties(Math::PI/4, 1.3, 1, 1000);
        m_render.reset(new Render::SimpleRender);
    }
示例#5
0
 COCA_API const IInfo& getInfo()
 {
     if ( !_info.get() ) { _info.reset( new Info() ); }
     return *_info;
 }
示例#6
0
 COCA_API IFactory& getFactory()
 {
     if ( !_factory.get() ) { _factory.reset( new Factory() ); }
     return *_factory;
 }
示例#7
0
//---------------------------------------------------------------------------------
AppConf::AppConf() :
	cf(static_cast<config_file *>(PlatformFactory::create_class_by_name("config_file")))
{
	add_entry("/apps/stardict/preferences/main_window/maximized", false);
#ifdef _WIN32
	add_entry("/apps/stardict/preferences/dictionary/use_custom_font", get_win32_use_custom_font());
#else
#ifdef CONFIG_DARWIN
	add_entry("/apps/stardict/preferences/dictionary/use_custom_font", get_darwin_use_custom_font());
#else
	add_entry("/apps/stardict/preferences/dictionary/use_custom_font", false);
#endif
#endif
#if defined(_WIN32) || defined(CONFIG_DARWIN)
	add_entry("/apps/stardict/preferences/network/enable_netdict", true);
#else
	add_entry("/apps/stardict/preferences/network/enable_netdict", false);
#endif
	// Default stardictd server.
	add_entry("/apps/stardict/preferences/network/server", std::string(_("dict.stardict.org")));
	add_entry("/apps/stardict/preferences/network/port", 2628);
	add_entry("/apps/stardict/preferences/network/user", std::string());
	add_entry("/apps/stardict/preferences/network/md5saltpasswd", std::string());
	// may store relative path
	add_entry("/apps/stardict/preferences/main_window/skin", std::string());
	add_entry("/apps/stardict/preferences/main_window/hide_on_startup", false);
	add_entry("/apps/stardict/preferences/main_window/search_while_typing", true);
	add_entry("/apps/stardict/preferences/main_window/word_change_timeout", 300);
	add_entry("/apps/stardict/preferences/main_window/showfirst_when_notfound", true);
	add_entry("/apps/stardict/preferences/translate/engine", 0);
	add_entry("/apps/stardict/preferences/translate/fromlang", 0);
	add_entry("/apps/stardict/preferences/translate/tolang", 0);
	add_entry("/apps/stardict/preferences/dictionary/enable_sound_event", true);
	add_entry("/apps/stardict/preferences/dictionary/use_tts_program", false);
	add_entry("/apps/stardict/preferences/dictionary/tts_program_cmdline", std::string()); // absolute command
	add_entry("/apps/stardict/preferences/main_window/hide_list", false);
	add_entry("/apps/stardict/preferences/dictionary/scan_selection", true);
	add_entry("/apps/stardict/preferences/dictionary/bookname_style", 0);
	add_entry("/apps/stardict/preferences/dictionary/markup_search_word", false);
#ifdef _WIN32
	add_entry("/apps/stardict/preferences/dictionary/scan_clipboard", false);
#endif
#ifndef CONFIG_DARWIN
	add_entry("/apps/stardict/preferences/dictionary/use_scan_hotkey", true);
	add_entry("/apps/stardict/preferences/dictionary/use_mainwindow_hotkey", true);
	add_entry("/apps/stardict/preferences/dictionary/scan_hotkey", std::string("<Ctrl><Alt>x"));
 	add_entry("/apps/stardict/preferences/dictionary/mainwindow_hotkey", std::string("<Ctrl><Alt>z"));
#endif
	add_entry("/apps/stardict/preferences/notification_area_icon/middle_click_action", int(namclaQueryFloatWindow));
	add_entry("/apps/stardict/preferences/dictionary/only_scan_while_modifier_key", false);
	add_entry("/apps/stardict/preferences/dictionary/hide_floatwin_when_modifier_key_released", true);
	add_entry("/apps/stardict/preferences/floating_window/pronounce_when_popup", false);
	add_entry("/apps/stardict/preferences/floating_window/lock", false);
	add_entry("/apps/stardict/preferences/floating_window/show_if_not_found", true);
	add_entry("/apps/stardict/preferences/floating_window/use_custom_bg", false);
#if GTK_MAJOR_VERSION >= 3
	add_entry("/apps/stardict/preferences/floating_window/bg_red", 1.0);
	add_entry("/apps/stardict/preferences/floating_window/bg_green", 1.0);
	add_entry("/apps/stardict/preferences/floating_window/bg_blue", (51200/(double)65535));
#else
	add_entry("/apps/stardict/preferences/floating_window/bg_red", 65535);
	add_entry("/apps/stardict/preferences/floating_window/bg_green", 65535);
	add_entry("/apps/stardict/preferences/floating_window/bg_blue", 51200);
#endif
	add_entry("/apps/stardict/preferences/floating_window/transparent", 0);

	add_entry("/apps/stardict/preferences/floating_window/lock_x", 0);
	add_entry("/apps/stardict/preferences/floating_window/lock_y", 0);
	add_entry("/apps/stardict/preferences/dictionary/scan_modifier_key", 0);
	add_entry("/apps/stardict/preferences/main_window/transparent", 0);
	add_entry("/apps/stardict/preferences/main_window/hpaned_pos", DEFAULT_HPANED_POS);
	add_entry("/apps/stardict/preferences/main_window/window_width", DEFAULT_WINDOW_WIDTH);
	add_entry("/apps/stardict/preferences/main_window/window_height", DEFAULT_WINDOW_HEIGHT);
	add_entry("/apps/stardict/preferences/floating_window/max_window_width", DEFAULT_MAX_FLOATWIN_WIDTH);
	add_entry("/apps/stardict/preferences/floating_window/max_window_height", DEFAULT_MAX_FLOATWIN_HEIGHT);

#ifdef _WIN32
	add_entry("/apps/stardict/preferences/dictionary/custom_font", get_win32_custom_font());
#else
#ifdef CONFIG_DARWIN
	add_entry("/apps/stardict/preferences/dictionary/custom_font", get_darwin_custom_font());
#else
	add_entry("/apps/stardict/preferences/dictionary/custom_font", std::string());
#endif
#endif

	add_entry("/apps/stardict/preferences/dictionary/create_cache_file", true);
	add_entry("/apps/stardict/preferences/dictionary/enable_collation", false);
	add_entry("/apps/stardict/preferences/dictionary/collate_function", 0);
	add_entry("/apps/stardict/preferences/dictionary/do_not_load_bad_dict", true);
	//add_entry("/apps/stardict/preferences/dictionary/add_new_dict_in_active_group", true);
	//add_entry("/apps/stardict/preferences/dictionary/add_new_plugin_in_active_group", true);

#if defined(_WIN32)
	add_entry("/apps/stardict/preferences/dictionary/sound_play_command", std::string("play")); // absolute command
	add_entry("/apps/stardict/preferences/dictionary/always_use_sound_play_command", false);
#else
	add_entry("/apps/stardict/preferences/dictionary/sound_play_command", std::string("aplay")); // absolute command
#endif
	add_entry("/apps/stardict/preferences/dictionary/video_play_command", std::string("play")); // absolute command
#if defined(CONFIG_GPE)
	add_entry("/apps/stardict/preferences/dictionary/url_open_command", std::string("gpe-mini-browser"));
#else
	add_entry("/apps/stardict/preferences/dictionary/url_open_command", std::string("firefox")); // absolute command
#endif
#if defined(_WIN32) || defined(CONFIG_GNOME)
	add_entry("/apps/stardict/preferences/dictionary/always_use_open_url_command", false);
#endif
	{
		std::list<std::string> pathlist;
#ifdef _WIN32
		pathlist.push_back("C:\\Program Files\\WyabdcRealPeopleTTS");
		pathlist.push_back("C:\\Program Files\\OtdRealPeopleTTS");
		pathlist.push_back("WyabdcRealPeopleTTS");
		pathlist.push_back("OtdRealPeopleTTS");
		// stores absolute and relative paths
		add_entry("/apps/stardict/preferences/dictionary/tts_path", pathlist);
#else
		pathlist.push_back("/usr/share/WyabdcRealPeopleTTS");
		pathlist.push_back("/usr/share/OtdRealPeopleTTS");
		add_entry("/apps/stardict/preferences/dictionary/tts_path", pathlist);
#endif
	}
	// may store relative path
	add_entry("/apps/stardict/preferences/dictionary/history", get_default_history_filename());
	add_entry("/apps/stardict/preferences/dictionary/only_export_word", true);
	// may store relative path
	add_entry("/apps/stardict/preferences/dictionary/export_file", get_default_export_filename());

	add_entry("/apps/stardict/preferences/main_window/search_website_list", std::list<std::string>());
	// stores absolute and relative paths
	add_entry("/apps/stardict/manage_dictionaries/treedict_order_list", std::list<std::string>());
	// stores absolute and relative paths
	add_entry("/apps/stardict/manage_dictionaries/treedict_disable_list", std::list<std::string>());
	add_entry("/apps/stardict/manage_dictionaries/dict_order_list", std::list<std::string>());
	// stores absolute and relative paths
	add_entry("/apps/stardict/manage_dictionaries/dict_config_xml", std::string());
	add_entry("/apps/stardict/manage_dictionaries/dict_default_group", std::string());

	// stores absolute and relative paths
	add_entry("/apps/stardict/manage_plugins/plugin_order_list", std::list<std::string>());
	// stores absolute and relative paths
	add_entry("/apps/stardict/manage_plugins/plugin_disable_list", std::list<std::string>());

	std::list<std::string> dirs;
	{
		std::string dir(build_path(conf_dirs->get_data_dir(), "dic"));
#ifdef _WIN32
		dirs.push_back(rel_path_to_data_dir(dir));
#else
		dirs.push_back(dir);
#endif
	}
#ifndef _WIN32
	if (conf_dirs->get_data_dir() != "/usr/share/stardict") {
		dirs.push_back("/usr/share/stardict/dic");
	}
	dirs.push_back(std::string(g_get_home_dir())+"/.stardict/dic");
#endif
	// stores absolute and relative paths
	add_entry("/apps/stardict/manage_dictionaries/dict_dirs_list", dirs);

	dirs.clear();
	{
		std::string dir(build_path(conf_dirs->get_data_dir(), "treedict"));
#ifdef _WIN32
		dirs.push_back(abs_path_to_data_dir(dir));
#else
		dirs.push_back(dir);
#endif
	}
#ifndef _WIN32
	dirs.push_back(std::string(g_get_home_dir())+"/.stardict/treedict");
#endif
	// stores absolute and relative paths
	add_entry("/apps/stardict/manage_dictionaries/treedict_dirs_list", dirs);

	Load();
}
示例#8
0
void
Section::AddReloc(std::auto_ptr<Reloc> reloc)
{
    m_relocs.push_back(reloc.release());
}
 void ClientMessageBuilder::addToPartialMessages(std::auto_ptr<ClientMessage> message) {
     int64_t id = message->getCorrelationId();
     partialMessages[id] = message.release();
 }
 void sendNotification(const T& t)
 {
     mMulticastSender->sendTo(mMulticastAddr, (const char*) &t, sizeof(t));
 }
示例#11
0
static
int zigbee_start( bool waitFlag = true )
{
	int ret;
	uint16 delay = 0;
	GeneralCallbackPtr pcb;
	CallbackProcessorFunc oldProcessor;

#ifndef ZIGBEE_COORDINATOR
	static const uint16 outClusters[] = { ZCL_CLUSTER_ID_GEN_ON_OFF };
#endif

	DBG( "zigbee_start() waitFlag = %s", waitFlag ? "true" : "false" );

	if( waitFlag ) {
#ifdef ZIGBEE_COORDINATOR	
		if( ret = zigbee_register_app(COORD_ENDPOINT, ZCL_HA_PROFILE_ID, ZCL_HA_DEVICEID_COMBINED_INETRFACE, DEVICEVERSION, 0, NULL, 0, NULL) ) {
			DBG( "zigbee_register_app() error %d", ret );
//			return ret;
		}
#else
		if( ret = zigbee_register_app(ENDDEV_ENDPOINT, ZCL_HA_PROFILE_ID, ZCL_HA_DEVICEID_ON_OFF_SWITCH, DEVICEVERSION, 0, NULL, ARRLEN(outClusters), outClusters) ) {
			DBG( "zigbee_register_app() error %d", ret );
//			return ret;
		}
#endif // ZIGBEE_COORDINATOR
	} // waitFlag

	// wait for state change to 9 or 6
	if( waitFlag ) {
		pcb = callbackParserTable.find( ZDO_STATE_CHANGE_IND )->second;
		oldProcessor = pcb->setProcessor( zigbee_start_cb );
		pcb->reset();
	}

#ifdef HOST_ZDEV_ENDIAN_DIFF
	BYTESWAP( &delay, uint16 );
#endif

	if( (ret = do_zdev_cmd(ZDO_STARTUP_FROM_APP, ZDO_STARTUP_FROM_APP_SRSP, &delay, 2)) ) {
		DBG( "do_zdev_cmd error" );
		return ret;
	}

	std::auto_ptr<ZigbeePayload> pResult( (ZigbeePayload*)(cmdSRSPCallbackPtr->getCbData()) );
	ret = *(pResult->data());
	if( ret && ret != 1 ) {
		DBG( "zigbee_start() invalid SRSP status %x", ret );
		return ret;
	}

//	DBG( "zigbee_start() retcode = %d", ret );

	if( waitFlag ) {
		if( ret = pcb->wait() ) {
			DBG( "wait for AREQ callback error." );
			return ret;
		}
		pcb->setProcessor( oldProcessor );
	}


	if( (ret = get_coord_info()) )
		return ret;

#ifdef _DEBUG
	print_coord_info();
#endif

//	DBG( "zigbee_start() finish!" );
	
	return 0;
}
示例#12
0
int zigbee_init( char *dev_name, uint8 type, uint8 clearOpt, int baudrate, int flow_ctrl, 
			int databits, int stopbits, int parity )
{
	int fd, ret, i;
	bool configChange;
	bool hasReset = false;

#ifdef _DEBUG
	zigbeelog1 = fopen( zigbeelog1_filename, "w" );
	setbuf( zigbeelog1, NULL ); 
	zigbeelog2 = fopen( zigbeelog2_filename, "w" );
	setbuf( zigbeelog2, NULL ); 
#endif	
	DBG( "ZigWay SDK Version: %s", ZIGBEE_VERSION );
	DBG( "zigbee_init %s type = %d, clearOpt = %d", dev_name, type, clearOpt );
//	DBG( "ZIGBEE_LOG1 = %s", ZIGBEE_LOG1 );

	fd = OpenSerial(fd, dev_name);
	if( fd < 0 ) {
		ret = fd;
		DBG( "Cannot open device %s", dev_name );
		perror( "Open device fail." );
		goto FAIL;
	}

	ret = InitSerial(fd, baudrate, flow_ctrl, databits, stopbits, parity);
	if( ret ) {
		DBG( "InitSerial fail." );
		perror( "InitSerial error!" );
		goto FAIL;
	}

	zigbee_fd = fd;
	
	
	//!! old way of at cmd test can be added here

	// end of old test


	clear_all();

	/* init global table and list for at command and general commands */
	prepare_callback();	

	// create and run reading thread
	running = 1;
	ret = pthread_create( &routine_tid, NULL, working_routine, NULL );
	if( ret ) {
		DBG( "start thread error: %s", strerror(ret) );
		goto FAIL;
	}

	DBG( "working_routine started. thread id = %lu", pthread_self() );

	// check nv configs
//	if( clearOpt )
//		reset = true;

	thisDev.reset( new ZigbeeCoord );

	if( clearOpt & STARTOPT_CLEAR_CONFIG ) {
		DBG( "STARTOPT_CLEAR_CONFIG is set" );
		hasReset = true;
		if( ret = write_nv_config(ZCD_NV_STARTUP_OPTION, &clearOpt, 1) )
			goto FAIL;
		zigbee_reset();
		zigbee_start( false );
		clearOpt &= ~STARTOPT_CLEAR_CONFIG;
		do_check_config( type, clearOpt, configChange );
		zigbee_reset();
	} else {
		do_check_config( type, clearOpt, configChange );
	} // if clearOpt

	if( !hasReset )
		zigbee_reset();	// always reset despite configChange
	if( ret = zigbee_start() )
		goto FAIL;
	
	return 0;
FAIL:
	WAIT( "Zigbee init fail, press Enter to go on." );
	DBG( "zigbee init fail, retcode = %d", ret );
	if( routine_tid ) {
		zigbee_finalize();
	} else {
		running = 0;
		routine_tid = 0;
		clear_all();
		close( fd );
	}
	return ret;
}
示例#13
0
 std::ofstream& file() {
     if (p_file.get() == NULL) throw error("not a file");
     return *p_file.get();
 }
示例#14
0
 std::ostringstream& stringstream() {
     if (p_stringstream.get() == NULL) throw error("not a stringstream");
     return *p_stringstream.get();
 }
示例#15
0
odbc::Mutex & DMAccessMutex()
{
	// Here we wrap into auto ptr, because of failing on muliple shutdown calls.
	static std::auto_ptr<odbc::Mutex> mtx(ODBCXX_OPERATOR_NEW_DEBUG(__FILE__, __LINE__) odbc::Mutex());
	return *(mtx.get());
}
HRESULT InitTerrainRender()
{
	HRESULT hr = S_OK;

	float fFinestLevelTriangError = g_fElevationSamplingInterval / 4.f;

	g_pTriangDataSource.reset( new CTriangDataSource );

	CHAR str[MAX_PATH];
		
	WideCharToMultiByte( CP_ACP, 0, g_strEncodedRQTTriangFile, -1, str, MAX_PATH, NULL, FALSE );
	
	//hr = DXUTFindDXSDKMediaFileCch( str, MAX_PATH, g_strEncodedRQTTriangFile );

	bool bCreateAdaptiveTriang = g_bForceRecreateTriang;
	if( !bCreateAdaptiveTriang )
	{
		if( SUCCEEDED(hr) )
		{
			// Try load triangulation data file
			hr = g_pTriangDataSource->LoadFromFile(str);
			if( SUCCEEDED(hr) )
			{
				if( g_pTriangDataSource->GetNumLevelsInHierarchy() != g_pElevDataSource->GetNumLevelsInHierarchy() ||
					g_pTriangDataSource->GetPatchSize() != g_pElevDataSource->GetPatchSize() )
					bCreateAdaptiveTriang =  true; // Incorrect parameters
			}
			else
				bCreateAdaptiveTriang = true; // Loading failed
		}
		else
			bCreateAdaptiveTriang = true; // File not found
	}

	// Init empty adaptive triangulation data source if file was not found or other problem occured
	if( bCreateAdaptiveTriang )
	{
		g_pTriangDataSource->Init( g_pElevDataSource->GetNumLevelsInHierarchy(), g_pElevDataSource->GetPatchSize(), fFinestLevelTriangError );
	}

	g_TerrainDX11Render.Init(g_TerrainRenderParams, g_DX11PatchRenderParams, g_pElevDataSource.get(), g_pTriangDataSource.get() );

	// Create adaptive triangulation if file was not found or other problem occured
	if( bCreateAdaptiveTriang )
	{
		g_TerrainDX11Render.ConstructPatchAdaptiveTriangulations();
		hr = g_pTriangDataSource->SaveToFile(str);
	}

	SPatchBoundingBox TerrainAABB;
	g_TerrainDX11Render.GetTerrainBoundingBox(TerrainAABB);

	return S_OK;
}
示例#17
0
bool
Publisher::run (void)
{
  ::DDS::DomainId_t domain_id = 411;

  try
    {
      sync_client_->way_point_reached (1);
      sync_client_->get_notification ();

      ACE_High_Res_Timer participant_timer;
      participant_timer.start();
      for (size_t count = 0; count < participant_count_; count++)
        {
          participant_[count] =
            dpf_->create_participant (domain_id,
                                      PARTICIPANT_QOS_DEFAULT,
                                      DDS::DomainParticipantListener::_nil(),
                                      ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
          if (CORBA::is_nil (participant_[count].in ())) {
            cerr << "create_participant failed." << endl;
            return false;
          }
        }
      participant_timer.stop();

      Messenger::MessageTypeSupport_var mts = new Messenger::MessageTypeSupportImpl();

      for (size_t count = 0; count < participant_count_; count++)
        {
          if (DDS::RETCODE_OK != mts->register_type(participant_[count].in (), "")) {
            cerr << "register_type failed." << endl;
            return false;
          }
        }

      CORBA::String_var type_name = mts->get_type_name ();

      DDS::TopicQos topic_qos;
      participant_[0]->get_default_topic_qos(topic_qos);

      ACE_High_Res_Timer topic_timer;
      topic_timer.start();
      for (size_t count = 0; count < topic_count_; count++)
        {
          topic_[count] =
            participant_[count % participant_count_]->create_topic ("Movie Discussion List",
                                                                    type_name.in (),
                                                                    topic_qos,
                                                                    DDS::TopicListener::_nil(),
                                                                    ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
          if (CORBA::is_nil (topic_[count].in ())) {
            cerr << "create_topic failed." << endl;
            return false;
          }
        }
      topic_timer.stop();

      ACE_High_Res_Timer pub_timer;
      pub_timer.start();
      for (size_t count = 0; count < writer_count_; count++)
        {
          // Create the publisher
          pub_[count] =
            participant_[count]->create_publisher(PUBLISHER_QOS_DEFAULT,
                                                  DDS::PublisherListener::_nil(),
                                                  ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);

          if (CORBA::is_nil (pub_[count].in ())) {
            cerr << "create_publisher failed." << endl;
            return false;
          }
        }

      // Create the datawriter
      DDS::DataWriterQos dw_qos;
      pub_[0]->get_default_datawriter_qos (dw_qos);

      for (size_t count = 0; count < writer_count_; count++)
        {
          dw_[count] =
            pub_[count]->create_datawriter(topic_[count].in (),
                                   dw_qos,
                                   DDS::DataWriterListener::_nil(),
                                   ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
          if (CORBA::is_nil (dw_[count].in ())) {
            cerr << "create_datawriter failed." << endl;
            return false;
          }
        }

      // Wait for all expected subscribers
      while (true)
        {
          ::DDS::InstanceHandleSeq handles;
          dw_[0]->get_matched_subscriptions(handles);
          //ACE_DEBUG ((LM_DEBUG, "(%P|%t) subs connected: %d\n", handles.length()));
          if (handles.length() >= subscriber_count_) {
            break;
          }
          ACE_OS::sleep (1);
        }
      pub_timer.stop ();

      // sync up
      sync_client_->way_point_reached (2);
      sync_client_->get_notification ();


      ACE_Time_Value tv;
      participant_timer.elapsed_time (tv);
      sync_client_->publish (SyncExt::Topic, static_cast<int>(topic_count_), tv.msec());
      //ACE_DEBUG ((LM_DEBUG, "(%P|%t) Created %d participants in %d secs.\n"
      //, participant_count_, tv.sec()));

      topic_timer.elapsed_time (tv);
      sync_client_->publish (SyncExt::Participant, static_cast<int>(participant_count_),
                             tv.msec());
      //ACE_DEBUG ((LM_DEBUG, "(%P|%t) Created %d topics in %d secs.\n"
      //, topic_count_, tv.sec()));

      pub_timer.elapsed_time (tv);
      sync_client_->publish (SyncExt::Publisher, static_cast<int>(writer_count_),
                             tv.msec());
      //ACE_DEBUG ((LM_DEBUG, "(%P|%t) Created %d publishers in %d secs.\n"
      //, writer_count_, tv.sec()));


      /*
        std::auto_ptr<Writer> writer (new Writer(dw_[0].in()));

        writer->start ();
        while ( !writer->is_finished()) {
        ACE_Time_Value small(0,250000);
        ACE_OS::sleep (small);
        }

        // Cleanup
        writer->end ();
        //delete writer;
        */

      for (size_t count = 0; count < participant_count_; count++)
        {
          participant_[count]->delete_contained_entities ();
          dpf_->delete_participant (participant_[count].in ());
        }
      TheServiceParticipant->shutdown ();
  }
  catch (CORBA::Exception& e)
    {
      cerr << "PUB: Exception caught in Publisher::run():\n  "
           << e << endl;
       return false;
    }

  return true;
}
示例#18
0
namespace coca
{
    std::auto_ptr<Logger> _logger;
    std::auto_ptr<Utils> _utils;
    std::auto_ptr<Info> _info;
    std::auto_ptr<Clock> _clock;
    std::auto_ptr<EventManager> _eventManager;
    std::auto_ptr<PluginManager> _pluginManager;
    std::auto_ptr<Factory> _factory;

    COCA_API const IInfo& getInfo()
    {
        if ( !_info.get() ) { _info.reset( new Info() ); }
        return *_info;
    }

    COCA_API ILogger& getLogger()
    {
        if ( !_logger.get() ) { _logger.reset( new Logger() ); }
        return *_logger;
    }

    COCA_API IPluginManager& getPluginManager()
    {
        if ( !_pluginManager.get() )
        {
            _pluginManager.reset( new PluginManager() );
            _pluginManager->registerLoader( PluginLoader::CREATE_FUNCTION_NAME, &create<IPluginLoader,PluginLoader> );
        }
        return *_pluginManager;
    }

    COCA_API IFactory& getFactory()
    {
        if ( !_factory.get() ) { _factory.reset( new Factory() ); }
        return *_factory;
    }

    COCA_API IEventManager& getEventManager()
    {
        if ( !_eventManager.get() ) { _eventManager.reset( new EventManager() ); }
        return *_eventManager;
    }

    COCA_API IClock& getClock()
    {
        if ( !_clock.get() ) { _clock.reset( new Clock() ); }
        return *_clock;
    }

    COCA_API IUtils& getUtils()
    {
        if ( !_utils.get() ) { _utils.reset( new Utils() ); }
        return *_utils;
    }

    COCA_API void destroyAll()
    {
        _factory.reset();
        _pluginManager.reset();
        _eventManager.reset();
        _clock.reset();
        _info.reset();
        _utils.reset();
        _logger.reset();
    }

} // namespace coca
示例#19
0
 void tick (const Daisy& daisy, const Scope& scope, Treelog& msg)
 { 
   if (action.get ())
     action->tick (daisy, scope, msg); 
 }
示例#20
0
 COCA_API ILogger& getLogger()
 {
     if ( !_logger.get() ) { _logger.reset( new Logger() ); }
     return *_logger;
 }
示例#21
0
  void doIt (Daisy& daisy, const Scope& scope, Treelog& msg)
  { 
    if (action.get () && action->done (daisy, scope, msg))
	action.reset (NULL);
    if (!action.get ())
      {
	action.reset(Librarian::build_frame<Action> (metalib, 
                                                     msg, *repeat, "repeat"));
	action->initialize (daisy, scope, msg);
	if (!action->check (daisy, scope, msg))
          action.reset (NULL);
	else
	  action->tick (daisy, scope, msg);
      }
    if (action.get ())         // Build free may fail.
      action->doIt (daisy, scope, msg);
  }
示例#22
0
 COCA_API IEventManager& getEventManager()
 {
     if ( !_eventManager.get() ) { _eventManager.reset( new EventManager() ); }
     return *_eventManager;
 }
示例#23
0
 void output (Log& log) const
 { 
   if (action.get ())
     output_object (action, "do", log);
 }
示例#24
0
 COCA_API IUtils& getUtils()
 {
     if ( !_utils.get() ) { _utils.reset( new Utils() ); }
     return *_utils;
 }
示例#25
0
  bool DistributeContent::UpLoadFile4(const std::string &url , const std::string &filename , const std::string &filetype ,
	 const std::string &localpath , const std::string &shopname ,std::auto_ptr<DistributeProgress> process)
 {

	 CURL * curl = curl_easy_init();

	 bool flag = true;

	 DynamicData data;
	 static const char buf[] = "Expect:";  
	 struct curl_httppost *formpost = NULL;
	 struct curl_httppost *lastptr = NULL;
	 struct curl_slist	 *headerlist = NULL;
	 void *progress_data[2];
	 progress_data[0] = process.get();
	 progress_data[1] = curl;

	 headerlist = curl_slist_append(headerlist, buf);  

	 curl_formadd(&formpost ,
		 &lastptr , 
		 CURLFORM_COPYNAME , "file",
		 CURLFORM_FILE , localpath.c_str(),
		 CURLFORM_FILENAME, filename.c_str(),
		 CURLFORM_CONTENTTYPE, filetype.c_str(),
		 CURLFORM_END
		 );

	 curl_formadd(&formpost , 
		 &lastptr,
		 CURLFORM_COPYNAME, "name",
		 CURLFORM_COPYCONTENTS,shopname.c_str(),
		 CURLFORM_END
		 );


	 curl_formadd(&formpost ,
		 &lastptr , 
		 CURLFORM_COPYNAME , "submit",
		 CURLFORM_END
		 );


	 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());		
	 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); 
	 curl_easy_setopt(curl, CURLOPT_HTTPPOST , formpost);
	 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, DistributeThread::write_data);
	 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
	 curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);                
	 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, DistributeProgress::HandlerProgressFunc);
	 curl_easy_setopt(curl , CURLOPT_PROGRESSDATA,progress_data);
	 curl_easy_setopt(curl , CURLOPT_LOW_SPEED_LIMIT , CURL_LOW_SPEED_LIMIT/1024);
	 curl_easy_setopt(curl , CURLOPT_LOW_SPEED_TIME , CURL_LOW_SPEED_TIME);
	 curl_easy_setopt(curl , CURLOPT_CONNECTTIMEOUT_MS , 3000);

	 CURLcode code =	curl_easy_perform(curl);
	 if(code != CURLE_OK)
	 {
		 flag = false;
	 }
	 if(code == CURLE_OK)
	 {
		 long retcode;
		 curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE , &retcode); 
		 if(retcode != 200)
		 {
			 flag = false;
		 }
	 }

	 curl_easy_cleanup(curl);
	 curl_formfree(formpost);  
	 curl_slist_free_all (headerlist);  

	 return flag;
 }
示例#26
0
 virtual void get_histogram_dimensions(size_t & n, double & xmin, double & xmax) const{
     hf->get_histogram_dimensions(n, xmin, xmax);
 }
示例#27
0
 explicit scoped_ptr( std::auto_ptr<T> p ): px( p.release() ) // never throws
 {
 }
示例#28
0
bool DatabaseUtils::GetDatabaseResults(MediaType mediaType, const FieldList &fields, const std::auto_ptr<dbiplus::Dataset> &dataset, DatabaseResults &results)
{
    if (dataset->num_rows() == 0)
        return true;

    const dbiplus::result_set &resultSet = dataset->get_result_set();
    unsigned int offset = results.size();

    if (fields.empty())
    {
        DatabaseResult result;
        for (unsigned int index = 0; index < resultSet.records.size(); index++)
        {
            result[FieldRow] = index + offset;
            results.push_back(result);
        }

        return true;
    }

    if (resultSet.record_header.size() < fields.size())
        return false;

    std::vector<int> fieldIndexLookup;
    fieldIndexLookup.reserve(fields.size());
    for (FieldList::const_iterator it = fields.begin(); it != fields.end(); it++)
        fieldIndexLookup.push_back(GetFieldIndex(*it, mediaType));

    results.reserve(resultSet.records.size() + offset);
    for (unsigned int index = 0; index < resultSet.records.size(); index++)
    {
        DatabaseResult result;
        result[FieldRow] = index + offset;

        unsigned int lookupIndex = 0;
        for (FieldList::const_iterator it = fields.begin(); it != fields.end(); it++)
        {
            int fieldIndex = fieldIndexLookup[lookupIndex++];
            if (fieldIndex < 0)
                return false;

            std::pair<Field, CVariant> value;
            value.first = *it;
            if (!GetFieldValue(resultSet.records[index]->at(fieldIndex), value.second))
                CLog::Log(LOGWARNING, "GetDatabaseResults: unable to retrieve value of field %s", resultSet.record_header[fieldIndex].name.c_str());

            if (value.first == FieldYear &&
                    (mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode))
            {
                CDateTime dateTime;
                dateTime.SetFromDBDate(value.second.asString());
                if (dateTime.IsValid())
                {
                    value.second.clear();
                    value.second = dateTime.GetYear();
                }
            }

            result.insert(value);
        }

        result[FieldMediaType] = mediaType;
        switch (mediaType)
        {
        case MediaTypeMovie:
        case MediaTypeVideoCollection:
        case MediaTypeTvShow:
        case MediaTypeMusicVideo:
            result[FieldLabel] = result.at(FieldTitle).asString();
            break;

        case MediaTypeEpisode:
        {
            std::ostringstream label;
            label << (int)(result.at(FieldSeason).asInteger() * 100 + result.at(FieldEpisodeNumber).asInteger());
            label << ". ";
            label << result.at(FieldTitle).asString();
            result[FieldLabel] = label.str();
            break;
        }

        case MediaTypeAlbum:
            result[FieldLabel] = result.at(FieldAlbum).asString();
            break;

        case MediaTypeSong:
        {
            std::ostringstream label;
            label << (int)result.at(FieldTrackNumber).asInteger();
            label << ". ";
            label << result.at(FieldTitle).asString();
            result[FieldLabel] = label.str();
            break;
        }

        case MediaTypeArtist:
            result[FieldLabel] = result.at(FieldArtist).asString();
            break;

        default:
            break;
        }

        results.push_back(result);
    }

    return true;
}
示例#29
0
int main(int argc, char** argv)
{

    try
    {
        // create a parser and add our options to it
        cli::ArgumentParser parser;
        parser.setDescription(
                              "This program reads in a single SICD or SIDD file and dumps its images as separate files.");
        parser.addArgument("-d --dir", "Write to output directory", cli::STORE)->setDefault(
                                                                                            ".");
        parser.addArgument("--sr", "Start Row", cli::STORE, "startRow", "ROW")->setDefault(
                                                                                           0);
        parser.addArgument("--nr", "Number of Rows", cli::STORE, "numRows",
                           "ROWS")->setDefault(-1);
        parser.addArgument("--sc", "Start Col", cli::STORE, "startCol", "COL")->setDefault(
                                                                                           0);
        parser.addArgument("--nc", "Number of Cols", cli::STORE, "numCols",
                           "COLS")->setDefault(-1);
        parser.addArgument("--sio", "Write out an SIO instead of a RAW file",
                           cli::STORE_TRUE, "sio");
        parser.addArgument("-s --schema",
                           "Specify a schema or directory of schemas",
                           cli::STORE);
        parser.addArgument("--one --single",
                           "Read input image in one read, rather than lines",
                           cli::STORE_TRUE, "oneRead");
        parser.addArgument("file", "SICD/SIDD input file", cli::STORE, "file",
                           "FILE", 1, 1);

        const std::auto_ptr<cli::Results>
            options(parser.parse(argc, (const char**) argv));

        long startRow(options->get<long> ("startRow"));
        long numRows(options->get<long> ("numRows"));
        long startCol(options->get<long> ("startCol"));
        long numCols(options->get<long> ("numCols"));
        bool isSIO(options->get<bool> ("sio"));
        bool oneRead(options->get<bool> ("oneRead"));
        std::string inputFile(options->get<std::string> ("file"));
        std::string outputDir(options->get<std::string> ("dir"));
        std::vector<std::string> schemaPaths;
        getSchemaPaths(*options, "--schema", "schema", schemaPaths);

        // create an XML registry
        // The reason to do this is to avoid adding XMLControlCreators to the
        // XMLControlFactory singleton - this way has more fine-grained control
        XMLControlRegistry xmlRegistry;
        xmlRegistry.addCreator(DataType::COMPLEX, new XMLControlCreatorT<
                six::sicd::ComplexXMLControl> ());
        xmlRegistry.addCreator(DataType::DERIVED, new XMLControlCreatorT<
                six::sidd::DerivedXMLControl> ());

        // create a Reader registry (now, only NITF and TIFF)
        ReadControlRegistry readerRegistry;
        readerRegistry.addCreator(new NITFReadControlCreator());
        readerRegistry.addCreator(new six::sidd::GeoTIFFReadControlCreator());

        // get the correct ReadControl for the given file
        const std::auto_ptr<ReadControl>
            reader(readerRegistry.newReadControl(inputFile));
        // set the optional registry, since we have one
        reader->setXMLControlRegistry(&xmlRegistry);

        // load the file
        reader->load(inputFile, schemaPaths);

        Container* container = reader->getContainer();
        std::string base = sys::Path::basename(inputFile, true);
        size_t numImages = 0;

        if (container->getDataType() == DataType::COMPLEX
                && container->getNumData() > 0)
        {
            numImages = 1;
        }
        else if (container->getDataType() == DataType::DERIVED)
        {
            for (; numImages < container->getNumData()
                    && container->getData(numImages)->getDataType()
                            == DataType::DERIVED; ++numImages)
                ;
        }

        std::cout << "Found: " << numImages << " image(s)" << std::endl;

        sys::OS os;
        if (!os.exists(outputDir))
            os.makeDirectory(outputDir);

        // first, write out the XMLs
        for (size_t i = 0, total = container->getNumData(); i < total; ++i)
        {
            const Data* data = container->getData(i);
            std::string filename = FmtX("%s_DES_%d.xml", base.c_str(), i);
            std::string xmlFile = sys::Path::joinPaths(outputDir, filename);
            io::FileOutputStream xmlStream(xmlFile);

            std::string xmlData = six::toXMLString(data, &xmlRegistry);
            xmlStream.write(xmlData.c_str(), xmlData.length());
            xmlStream.close();
        }

        //  now, dump the images
        for (size_t ii = 0; ii < numImages; ++ii)
        {
            const Data* const data = container->getData(ii);
            const size_t nbpp = data->getNumBytesPerPixel();
            const size_t height = data->getNumRows();
            const size_t width = data->getNumCols();

            if (numRows == -1)
                numRows = height;

            if (numCols == -1)
                numCols = width;

            const std::string filename =
                FmtX("%s_%d-%dx%d-%d_%d-image-%d.%s",
                     base.c_str(),
                     startRow,
                     startRow + numRows,
                     startCol,
                     startCol + numCols,
                     nbpp,
                     ii,
                     isSIO ? "sio" : "raw");

            const std::string outputFile =
                sys::Path::joinPaths(outputDir, filename);
            io::FileOutputStream outputStream(outputFile);

            if (isSIO)
            {
                writeSIOFileHeader(numRows,
                                   numCols,
                                   data->getPixelType(),
                                   outputStream);
            }

            Region region;
            region.setStartRow(startRow);
            region.setStartCol(startCol);
            region.setNumCols(numCols);

            if (oneRead)
            {
                region.setNumRows(numRows);
                size_t totalBytes = nbpp * numCols * numRows;
                const mem::ScopedArray<UByte>
                    workBuffer(new UByte[totalBytes]);
                region.setBuffer(workBuffer.get());

                reader->interleaved(region, ii);
                outputStream.write((const sys::byte*) workBuffer.get(),
                                   totalBytes);
            }
            else
            {
                region.setNumRows(1);
                size_t nbpr = nbpp * width;

                // allocate this so we can reuse it for each row
                const mem::ScopedArray<UByte> workBuffer(new UByte[nbpr]);
                region.setBuffer(workBuffer.get());

                for (unsigned int jj = startRow;
                     jj < numRows + startRow;
                     ++jj)
                {
                    region.setStartRow(jj);
                    UByte* line = reader->interleaved(region, ii);
                    outputStream.write((const sys::byte*) line, nbpr);
                }
            }
            outputStream.close();
            std::cout << "Wrote file: " << outputFile << std::endl;
        }
    }
    catch (const except::Exception& e)
    {
        std::cout << e.toString() << std::endl;
        exit(1);
    }
    catch (const std::exception& cppE)
    {
        std::cout << "C++ exception: " << cppE.what() << std::endl;
        exit(1);
    }
    catch (...)
    {
        std::cout << "Unknown exception" << std::endl;
        exit(1);
    }
    return 0;
}
示例#30
-1
void test_timer() {
    l.reset(new loop());
    l->add_timer(1, 2, timer_callback);
    l->run(4);
    l.reset(NULL);
}