コード例 #1
0
bool init_param_from_mpi(dc_init_param& param,dc_comm_type commtype) {
#ifdef HAS_MPI
    ASSERT_MSG(commtype == TCP_COMM, "MPI initialization only supports TCP at the moment");
    // Look for a free port to use.
    std::pair<size_t, int> port_and_sock = get_free_tcp_port();
    size_t port = port_and_sock.first;
    int sock = port_and_sock.second;

    std::string ipaddr =
        get_local_ip_as_str(mpi_tools::rank() == 0 /* print stuff only if I am master */);
    ipaddr = ipaddr + ":" + tostr(port);
    // now do an allgather
    logstream(LOG_INFO) << "Will Listen on: " << ipaddr << std::endl;
    std::vector<std::string> machines;
    mpi_tools::all_gather(ipaddr, param.machines);
    // set defaults
    param.curmachineid = (procid_t)(mpi_tools::rank());

    param.numhandlerthreads = RPC_DEFAULT_NUMHANDLERTHREADS;
    param.commtype = commtype;
    param.initstring = param.initstring + std::string(" __sockhandle__=") + tostr(sock) + " ";
    return true;
#else
    std::cerr << "MPI Support not compiled!" << std::endl;
    exit(0);
#endif
}
コード例 #2
0
ファイル: dc.cpp プロジェクト: RedSunCMX/graphlab
distributed_control::distributed_control() {
  dc_init_param initparam;
  if (init_param_from_env(initparam)) {
    logstream(LOG_INFO) << "Distributed Control Initialized from Environment" << std::endl;
  } else if (init_param_from_zookeeper(initparam)) {
      logstream(LOG_INFO) << "Distributed Control Initialized from Zookeeper" << std::endl;
  } else if (mpi_tools::initialized() && init_param_from_mpi(initparam)) {
      logstream(LOG_INFO) << "Distributed Control Initialized from MPI" << std::endl;
  }
  else {
    logstream(LOG_INFO) << "Shared Memory Execution" << std::endl;
    // get a port and socket
    std::pair<size_t, int> port_and_sock = get_free_tcp_port();
    size_t port = port_and_sock.first;
    int sock = port_and_sock.second;

    initparam.machines.push_back(std::string("localhost:") + tostr(port));
    initparam.curmachineid = 0;
    initparam.initstring = std::string(" __sockhandle__=") + tostr(sock) + " ";
    initparam.numhandlerthreads = RPC_DEFAULT_NUMHANDLERTHREADS;
    initparam.commtype = RPC_DEFAULT_COMMTYPE;
  }
  init(initparam.machines,
        initparam.initstring,
        initparam.curmachineid,
        initparam.numhandlerthreads,
        initparam.commtype);
  INITIALIZE_TRACER(dc_receive_queuing, "dc: time spent on enqueue");
  INITIALIZE_TRACER(dc_receive_multiplexing, "dc: time spent exploding a chunk");
  INITIALIZE_TRACER(dc_call_dispatch, "dc: time spent issuing RPC calls");
}
コード例 #3
0
ファイル: 0070-null_empty.cpp プロジェクト: Whissi/librdkafka
static int check_equal (const char *exp,
                         const char *actual, size_t len,
                         std::string what) {
  size_t exp_len = exp ? strlen(exp) : 0;
  int failures = 0;

  if (!actual && len != 0) {
    Test::FailLater(tostr() << what << ": expected length 0 for Null, not " << len);
    failures++;
  }

  if (exp) {
    if (!actual) {
      Test::FailLater(tostr() << what << ": expected \"" << exp << "\", not Null");
      failures++;

    } else if (len != exp_len || strncmp(exp, actual, exp_len)) {
      Test::FailLater(tostr() << what << ": expected \"" << exp << "\", not \"" << actual << "\" (" << len << " bytes)");
      failures++;
    }

  } else {
    if (actual) {
      Test::FailLater(tostr() << what << ": expected Null, not \"" << actual << "\" (" << len << " bytes)");
      failures++;
    }
  }

  if (!failures)
    Test::Say(3, tostr() << what << ": matched expectation\n");

  return failures;
}
コード例 #4
0
ファイル: MouseTest.cpp プロジェクト: fordream/Snake
void MouseTest::onMouseScroll(Event *event)
{
    EventMouse* e = (EventMouse*)event;
    std::string str = "Mouse Scroll detected, X: ";
    str = str + tostr(e->getScrollX()) + " Y: " + tostr(e->getScrollY());
    _labelAction->setString(str.c_str());
}
コード例 #5
0
void
AP_RDFEventGTK::updateFromEditorData( PD_DocumentRDFMutationHandle m )
{
    if (m_linkingSubject.toString().empty())
    {
        std::string uuid = XAP_App::getApp()->createUUIDString();
        m_linkingSubject = uuid;
    }

    // UT_DEBUGMSG(("updateFromEditorData() name:%s new-name:%s\n",
    //              m_name.c_str(), tostr(GTK_ENTRY(w_name)).c_str() ));
    
    std::string predBase = "http://www.w3.org/2002/12/cal/icaltzd#";
    setRDFType(   m, predBase + "Vevent" );
    updateTriple( m, m_uid,      m_uid, predBase + "uid");
//    updateTriple( m, m_name,       tostr(GTK_ENTRY(w_name)),    predBase + "name");
    updateTriple( m, m_summary,    tostr(GTK_ENTRY(w_summary)), predBase + "summary");
    updateTriple( m, m_location,   tostr(GTK_ENTRY(w_location)),predBase + "location");
    updateTriple( m, m_desc,       tostr(GTK_ENTRY(w_desc)),    predBase + "description");
//    updateTriple( m, m_uid,        tostr(GTK_ENTRY(w_uid)),     predBase + "uid");
    updateTriple( m, m_dtstart,    parseTimeString(tostr(GTK_ENTRY(w_dtstart))), predBase + "dtstart");
    updateTriple( m, m_dtend,      parseTimeString(tostr(GTK_ENTRY(w_dtend))),   predBase + "dtend");
    
    if (getRDF())
    {
//        getRDF()->emitSemanticObjectUpdated(this);
    }
    
}
コード例 #6
0
  /**
   * @brief Naiive JSON parsing, find the consumer_lag for partition 0
   * and return it.
   */
  static int64_t parse_json (const char *json_doc) {
    const std::string match_topic(std::string("\"") + topic + "\":");
    const char *search[] = { "\"topics\":",
                             match_topic.c_str(),
                             "\"partitions\":",
                             "\"0\":",
                             "\"consumer_lag\":",
                             NULL };
    const char *remain = json_doc;

    for (const char **sp = search ; *sp ; sp++) {
      const char *t = strstr(remain, *sp);
      if (!t)
        Test::Fail(tostr() << "Couldnt find " << *sp <<
                   " in remaining stats output:\n" << remain <<
                   "\n====================\n" << json_doc << "\n");
      remain = t + strlen(*sp);
    }

    while (*remain == ' ')
      remain++;

    if (!*remain)
      Test::Fail("Nothing following consumer_lag");

    int64_t lag = strtoull(remain, NULL, 0);
    if (lag == -1)
      Test::Say(tostr() << "Consumer lag " << lag << " is invalid, stats:\n" <<
                json_doc << "\n");
    return lag;
  }
コード例 #7
0
ファイル: data_filedb.cpp プロジェクト: Morgulas/gccg-dev
	void DataFileDB::SaveToDisk()
	{
		Dump("SaveToDisk()","save all data");
		
		if(dbtype==DBSingleFile)
		{
			WriteFile("type",TypeToString(DBSingleFile));
			WriteFile("value",tostr(*this).String());
		}
		else if(dbtype==DBStringKeys)
		{
			WriteFile("type",TypeToString(DBStringKeys));
			Data keys;
			keys.MakeList(status.size());
			for(size_t i=0; i<status.size(); i++)
			{
				keys[i].MakeList(2);
				keys[i][0]=vec[i][0];
				SaveCache(i);
			}
			WriteFile("keys",tostr(keys).String());				
		}
		else
			throw Error::NotYetImplemented("DataToDisk::SaveContent()");

		MarkAllClean();
	}
コード例 #8
0
ファイル: disk_graph.hpp プロジェクト: greeness/graphlab_CMU
 /**
  * Creates or opens a disk graph with base name 'fbasename' using 
  * 'numfiles' of atoms. The atoms will be named fbasename.0, fbasename.1
  * fbasename.2, etc. An atom index file will be created in fbasename.idx.
  * This is useful when either creating a new
  * disk graph, or to open a disk graph without an atom index.
  * 
  * \note finalize() will always rebuild an atom index file irregardless of
  * which constructor is used.
  */
 disk_graph(std::string fbasename, size_t numfiles, 
            disk_graph_atom_type::atom_type atype = disk_graph_atom_type::DISK_ATOM) {  
   atoms.resize(numfiles);
   atomtype = atype;
   numv.value = 0;
   nume.value = 0;
   
   for (size_t i = 0;i < numfiles; ++i) {
     if (atomtype == disk_graph_atom_type::DISK_ATOM) {
       atoms[i] = new disk_atom(fbasename + "." + tostr(i), i);
       numv.value += atoms[i]->num_vertices();
       nume.value += atoms[i]->num_edges();
     }
     else if (atomtype == disk_graph_atom_type::MEMORY_ATOM) {
       atoms[i] = new memory_atom(fbasename + "." + tostr(i) + ".fast", i);
       numv.value += atoms[i]->num_vertices();
       nume.value += atoms[i]->num_edges();
     }
     else if (atomtype == disk_graph_atom_type::WRITE_ONLY_ATOM) {
       atoms[i] = new write_only_disk_atom(fbasename + "." + tostr(i) + ".dump", i, true);
     }
   }
   indexfile = fbasename + ".idx";
   ncolors = vertex_color_type(-1);
 }
コード例 #9
0
ファイル: MouseTest.cpp プロジェクト: fordream/Snake
void MouseTest::onMouseMove(Event *event)
{
    EventMouse* e = (EventMouse*)event;
    std::string str = "MousePosition X:";
    str = str + tostr(e->getCursorX()) + " Y:" + tostr(e->getCursorY());
    _labelPosition->setString(str.c_str());
}
コード例 #10
0
ファイル: BlackADC.cpp プロジェクト: trih/huy_transfer
 // ########################################### BLACKADC DEFINITION STARTS ############################################ //
 BlackADC::BlackADC(adcName adc)
 {
     this->adcErrors                 = new errorADC( this->getErrorsFromCoreADC() );
     this->ainName                   = adc;
     this->ainPath                   = DEVICE_PATH +
                                       tostr("in_voltage") +
                                       tostr(this->ainName) +
                                       tostr("_raw") ;
 }
コード例 #11
0
ファイル: interval.cpp プロジェクト: nathanprat/tlp-gp
string Interval::to_string() {
	string str = "";
	if (m_start_bracket)
		str += "[";
	else
		str += "]";
	str += tostr(m_start) + "; " + tostr(m_end);
	if (m_end_bracket)
		str += "[";
	else
		str += "]";
	return str;
}
コード例 #12
0
ファイル: BlackUART.cpp プロジェクト: Barbalho12/DetectFaces
    BlackUART::BlackUART(uartName uart)
    {
        this->dtUartFilename            = "BB-UART" + tostr(static_cast<int>(uart));
        this->uartPortPath              = "/dev/ttyO" + tostr(static_cast<int>(uart));

        this->readBufferSize            = 1024;
        this->uartFD                    = -1;
        this->isOpenFlag                = false;
        this->isCurrentEqDefault        = true;

        this->uartErrors                = new errorUART( this->getErrorsFromCore() );

        this->loadDeviceTree();
    }
コード例 #13
0
ファイル: BlackUART.cpp プロジェクト: Barbalho12/DetectFaces
    BlackUART::BlackUART(uartName uart, baudRate uartBaud, parity uartParity, stopBits uartStopBits, characterSize uartCharSize)
    {
        this->dtUartFilename            = "BB-UART" + tostr(static_cast<int>(uart));
        this->uartPortPath              = "/dev/ttyO" + tostr(static_cast<int>(uart));

        this->readBufferSize            = 1024;
        this->uartFD                    = -1;
        this->isOpenFlag                = false;
        this->isCurrentEqDefault        = false;

        this->uartErrors                = new errorUART( this->getErrorsFromCore() );
        this->constructorProperties     = BlackUartProperties(uartBaud, uartBaud, uartParity, uartStopBits, uartCharSize);

        this->loadDeviceTree();
    }
コード例 #14
0
ファイル: data.cpp プロジェクト: Morgulas/gccg-dev
    size_t Data::KeyLookup(const Data& key,bool& already_exist) const
    {
	size_t min=0;
	size_t max=vec.size();
	size_t i=0;

	already_exist=true;
		
	while(min != max)
	{
	    i=(max+min)/2;

	    if(!vec[i].IsList(2))
		throw LangErr("Data::KeyLookup","dictionary contains invalid entry '"+tostr(vec[i]).String()+"'");

	    if(key==vec[i][0])
		return i;

	    if(key < vec[i][0])
		max=i;
	    else
		min=i+1;
	}

	if(i < vec.size() && vec[i][0]==key)
	    return i;

	already_exist=false;

	return min;
    }
コード例 #15
0
ファイル: misc.cpp プロジェクト: lnovy/tauchain
string dstr(int p) {
	if ( !deref ) return tostr(p);
	string s = dict[p];
	if ( !shorten ) return s;
	if ( s.find ( "#" ) == string::npos ) return s;
	return s.substr ( s.find ( "#" ), s.size() - s.find ( "#" ) );
}
コード例 #16
0
void preROTATE(string &line, RawSource *) {
    string nr;
    int val,rot,max;
    if (!ParseExpression(line,val)) {
        error1("Expression expected");
        return;
    }
    if (labelnotfound) {
        error1("Forward reference");
        return;
    }
    nr=macnumtab.getrepl(ROTATE);
    if (nr.empty()) {
        error1("use of rotate not allowed outside macro");
        return;
    }
    if (!getConstant(nr,rot)) error1("preROTATE",ERRINTERNAL);
    nr=macnumtab.getrepl(0);
    if (nr.empty()) {
        error1("use of rotate not allowed outside macro");
        return;
    }
    if (!getConstant(nr,max)) error1("preROTATE",ERRINTERNAL);
    rot=rot+val;
    while (rot<0) rot=rot+max;
    macnumtab.replace(ROTATE,tostr(rot));
}
コード例 #17
0
ファイル: data.cpp プロジェクト: Morgulas/gccg-dev
    void DoPrettySave(ostream& O,const Data& D)
    {
	if(D.IsList())
	{
	    const Data& L=D;

	    if(L.Size()==0)
		O << "(,)";
	    else
	    {
		if(pretty_save_indent)
		    O << endl;
		for(int i=pretty_save_indent; i>0; i--)
		    O << ' ';
		O << '(';
		pretty_save_indent+=2;
		for(size_t i=0; i<L.Size(); i++)
		{
		    DoPrettySave(O,L[i]);
		    O << ',';
		}
		pretty_save_indent-=2;
		O << ')';
	    }
	}
	else
	    O << tostr(D).String();
    }
コード例 #18
0
ファイル: LabelIncr.cpp プロジェクト: gdevillele/pxlframework
		LabelIncr* LabelIncr::newLabelIncr(const Point& anchor,
										   const Point& position,
										   int number,
										   const std::string& font,
										   Tick::Duration maximumTotalTime,
										   int minimumUpdateValue)
		{
			LabelIncr* result = new LabelIncr();
			
			// define MenuSprite specific attributes
			result->setAnchor(anchor);
			result->setPosition(position);
			
			// define Label specific attributes
			result->setNumber(number);
			result->_numberDisplayed = number;
			
			result->setText(tostr(number));
			result->setFont(font);
			
			result->setMaximumTotalTime(maximumTotalTime);
			result->setMinimumUpdateValue(minimumUpdateValue);
			
			
			return result;
		}
コード例 #19
0
ファイル: prim.c プロジェクト: l0stman/loot
/* Write the expression to the standard output. */
static exp_t *
prim_write(exp_t *args)
{
        chkargs("write", args, 1);
        printf("%s", tostr(car(args)));
        return NULL;
}
コード例 #20
0
ファイル: BlackPWM.cpp プロジェクト: trih/huy_transfer
    std::string BlackPWM::getValue()
    {
        double period   = static_cast<long double>( this->getNumericPeriodValue() );
        double duty     = static_cast<long double>( this->getNumericDutyValue() );

        return tostr(static_cast<float>( (1.0 - (duty / period )) * 100 ));
    }
コード例 #21
0
ファイル: data_filedb.cpp プロジェクト: Morgulas/gccg-dev
	void DataFileDB::LoadCache(int index) const
	{
		if(index < 0 || (size_t)index >= status.size())
			throw Error::Invalid("DataFileDB::LoadCache","invalid index "+ToString(index));
		
		if(dbtype==DBStringKeys)
		{
			Touch(index);
		
			if(!status[index].ondisk)
				return;

			Dump("DataFileDB::LoadCache(int)","loading entry "+ToString(index)+": "+tostr(vec[index][0]).String());
				
			string filename=FileName(vec[index][0].String());
			security.ReadFile(filename);
			ifstream F(filename.c_str());
			if(!F)
				throw Error::IO("DataFileDB::LoadCache(int)","unable to read "+filename);
		
			string buffer;
			while(F)
				buffer+=readline(F);
			F.close();
		
			status[index].ondisk=false;
			vec[index][1]=toval(buffer);
		}
		else
			throw Error::NotYetImplemented("DataFileDB::LoadCache()");
	}
コード例 #22
0
ファイル: data_filedb.cpp プロジェクト: Morgulas/gccg-dev
	bool DataFileDB::SaveCache(int index) const
	{
		if(index < 0 || (size_t)index >= status.size())
			throw Error::Invalid("DataFileDB::SaveCache","invalid index "+ToString(index));

		if(dbtype==DBStringKeys)
		{
			if(status[index].ondisk)
				return false;

			Dump("DataFileDB::SaveCache(int)","saving entry "+ToString(index)+": "+tostr(vec[index][0]).String());
		
			Touch(index);

			string filename=FileName(vec[index][0].String());
			security.WriteFile(filename);
		
			ofstream F(filename.c_str());
			if(!F)
				throw Error::IO("DataFileDB::SaveCache(int)","unable to write "+filename);
			PrettySave(F,vec[index][1]);
			F.close();

			status[index].ondisk=true;
			vec[index][1]=Null;
		}
		else
			throw Error::NotYetImplemented("DataFileDB::SaveCache()");
		
		return true;
	}
コード例 #23
0
ファイル: MouseTest.cpp プロジェクト: fordream/Snake
void MouseTest::onMouseUp(Event *event)
{
    EventMouse* e = (EventMouse*)event;
    std::string str = "Mouse Up detected, Key: ";
    str += tostr(e->getMouseButton());
    _labelAction->setString(str.c_str());
}
コード例 #24
0
void preXEXITMACRO(string &line, RawSource *) {
    int val;
    if (maclabp.empty()) error1("XEXITMACRO used outside macro");
    else stop._stop=EXITMACRO;
    ParseExpression(line,val);
    if (labelnotfound) error1("Forward reference");
    stop._retval=tostr(val);
}
コード例 #25
0
ファイル: matrixOpTester.hpp プロジェクト: KoloMK/MKNum
void testMatrixOperationsComplex() {
    std::cout << "testing MatrixOperations over std::complex" << std::endl;
    std::complex<double> data[12] = {{1,  -1},
        {2,  -2},
        {3,  -3},
        {4,  -4},
        {5,  -5},
        {6,  -6},
        {7,  -7},
        {8,  -8},
        {9,  -9},
        {10, -10},
        {11, -11},
        {12, -12}
    };
    CDMatrix test_matrix(3, 4, data);
    std::string test_string = "(1,-1) (2,-2) (3,-3) (4,-4) \n(5,-5) (6,-6) (7,-7) (8,-8) \n(9,-9) (10,-10) (11,-11) (12,-12) \n";
    std::string test_cs12 = "(1,-1) (3,-3) (2,-2) (4,-4) \n(5,-5) (7,-7) (6,-6) (8,-8) \n(9,-9) (11,-11) (10,-10) (12,-12) \n";
    std::string test_rs12 = "(1,-1) (3,-3) (2,-2) (4,-4) \n(9,-9) (11,-11) (10,-10) (12,-12) \n(5,-5) (7,-7) (6,-6) (8,-8) \n";
    std::string test_ra013 = "(28,-28) (36,-36) (32,-32) (40,-40) \n(9,-9) (11,-11) (10,-10) (12,-12) \n(5,-5) (7,-7) (6,-6) (8,-8) \n";
    std::string test_ca23m2 = "(28,-28) (36,-36) (-48,48) (40,-40) \n(9,-9) (11,-11) (-14,14) (12,-12) \n(5,-5) (7,-7) (-10,10) (8,-8) \n";
    std::string test_rm22 = "(28,-28) (36,-36) (-48,48) (40,-40) \n(9,-9) (11,-11) (-14,14) (12,-12) \n(10,-10) (14,-14) (-20,20) (16,-16) \n";
    std::string test_cm03 = "(84,-84) (36,-36) (-48,48) (40,-40) \n(27,-27) (11,-11) (-14,14) (12,-12) \n(30,-30) (14,-14) (-20,20) (16,-16) \n";
    std::string test_rg2 = "(84,-84) (36,-36) (-48,48) (40,-40) \n(27,-27) (11,-11) (-14,14) (12,-12) \n(-30,30) (-14,14) (20,-20) (-16,16) \n";
    std::string test_cg2 = "(84,-84) (36,-36) (48,-48) (40,-40) \n(27,-27) (11,-11) (14,-14) (12,-12) \n(-30,30) (-14,14) (-20,20) (-16,16) \n";
    Test tostr(test_string);
    Test tcs12(test_cs12);
    Test trs12(test_rs12);
    Test tra013(test_ra013);
    Test tca23m2(test_ca23m2);
    Test trm22(test_rm22);
    Test tcm03(test_cm03);
    Test trg2(test_rg2);
    Test tcg2(test_cg2);
    std::cout << "tostr:" << tostr.do_(test_matrix.toString()) << std::endl;
    test_matrix.colSwap(1, 2);
    std::cout << "tcs12:" << tcs12.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowSwap(1, 2);
    std::cout << "trs12:" << trs12.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowAdd(0, 1, 3);
    std::cout << "tra013:" << tra013.do_(test_matrix.toString()) << std::endl;
    test_matrix.colAdd(2, 3, -2);
    std::cout << "tca23m2:" << tca23m2.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowMultiply(2, 2);
    std::cout << "trm22:" << trm22.do_(test_matrix.toString()) << std::endl;
    test_matrix.colMultiply(0, 3);
    std::cout << "tcm03:" << tcm03.do_(test_matrix.toString()) << std::endl;
    test_matrix.rowSgnChange(2);
    std::cout << "trg2:" << trg2.do_(test_matrix.toString()) << std::endl;
    test_matrix.colSgnChange(2);
    std::cout << "tcg2:" << tcg2.do_(test_matrix.toString()) << std::endl;
    std::cout << "square:" << (test_matrix.isSquare() == 0) << std::endl;
    std::cout << "cols:" << (test_matrix.getNumOfCols() == 4) << std::endl;
    std::cout << "rows:" << (test_matrix.getNumOfRows() == 3) << std::endl;


}
コード例 #26
0
  void event_cb (RdKafka::Event &event) {
    switch (event.type())
      {
    case RdKafka::Event::EVENT_ERROR:
      Test::Say(tostr() << "Error: " << RdKafka::err2str(event.err()) <<
        ": " << event.str() << "\n");
      if (event.err() == RdKafka::ERR__ALL_BROKERS_DOWN)
        error_seen = true;
      break;

      case RdKafka::Event::EVENT_LOG:
        Test::Say(tostr() << "Log: " << event.str() << "\n");
        break;

      default:
      break;
    }
  }
コード例 #27
0
ファイル: BlackI2C.cpp プロジェクト: BBB-UNAM/Tesis
    BlackI2C::BlackI2C(i2cName i2c, unsigned int i2cDeviceAddress)
    {
        this->i2cPortPath   = "/dev/i2c-" + tostr(static_cast<int>(i2c));
        this->i2cDevAddress = i2cDeviceAddress;
        this->i2cFD         = -1;
        this->isOpenFlag    = false;

        this->i2cErrors     = new errorI2C( this->getErrorsFromCore() );
    }
コード例 #28
0
void InputManager::Initialize(Ogre::RenderWindow* window) {
    if(mInputSystem != nullptr) {
        Logger::Get().Warning("Input system already initialized. Aborting.");
        return;
    }

    mWindow = window;

    OIS::ParamList params;

    // getting window handle
    size_t window_handle = 0;
    mWindow->getCustomAttribute("WINDOW", &window_handle);
    params.insert(std::make_pair(std::string("WINDOW"), tostr(window_handle)));
    if(!mJailInput) {
#if defined OIS_WIN32_PLATFORM
        params.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
        params.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
        params.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
        params.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
        params.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
        params.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
        params.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
        params.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif
    }

    Logger::Get().Info("Initializing input system (Window: " + tostr(window_handle) + ")");
    mInputSystem = OIS::InputManager::createInputSystem(params);

    mKeyboard = static_cast<OIS::Keyboard*>(mInputSystem->createInputObject(OIS::OISKeyboard, true));
    mMouse = static_cast<OIS::Mouse*>(mInputSystem->createInputObject(OIS::OISMouse, true));

    mKeyboard->setEventCallback(this);
    mMouse->setEventCallback(this);

    // Set initial mouse clipping size
    windowResized(mWindow);

    // Register as a Window listener
    Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
}
コード例 #29
0
void preASSIGN(string &line, RawSource *) {
    string d=getid(line);
    string p=ReplaceDefines(line);
    line.clear();
    int val;
    if (!ParseExpression(p,val)) error1("Expression expected");
    if (labelnotfound) error1("Forward reference");
    checkjunk(p);
    deftab.add(d,tostr(val));
}
コード例 #30
0
void preSTRLEN(string &line, RawSource *) {
    string e;
    string d=getid(line);
    skipblanks(line);
    string p=ReplaceDefines(line);
    line.clear();
    getstring(p,e);
    checkjunk(p);
    deftab.add(d,tostr(e.size()));
}