• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Topic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Topic的典型用法代码示例。如果您正苦于以下问题:C++ Topic类的具体用法?C++ Topic怎么用?C++ Topic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getTopic

uint16_t Topics::getTopicId(MQString* topic){
    Topic *p = getTopic(topic);
    if ( p != NULL) {
        return p->getTopicId();
    }
    return 0;
}
开发者ID:cxcco,项目名称:MQTT-S,代码行数:7,代码来源:MQTTS.cpp


示例2: Topic

/*=====================================
        Class Topics
 ======================================*/
Topics::Topics(){
	Topic* tp = new Topic(string(MQTTSN_TOPIC_PREDEFINED_TIME));
	tp->setTopicId(MQTTSN_TOPICID_PREDEFINED_TIME);
	_topics.push_back(tp);
	_cnt = 1;
	_nextTopicId = MQTTSN_TOPICID_NORMAL;
}
开发者ID:cxcco,项目名称:MQTT-S-Gateway,代码行数:10,代码来源:Topics.cpp


示例3: getTopic

int Topics::execCallback(MQString* topic, MqttsnPublish* msg) {
    Topic* p = getTopic(topic);
    if ( p != 0) {
        return p->execCallback(msg);
    }
    return 0;
}
开发者ID:rpurser47,项目名称:MQTT-SN,代码行数:7,代码来源:mqttsn.cpp


示例4: get

String WIFI::get(Topic &topic) {
  if (topic.itemIs(3, "macAddress")) {
    return macAddress();
  } else if (topic.itemIs(3, "scanResult")){
    return scanResult();
  } else {
    return TOPIC_NO;
  }
}
开发者ID:Pfannex,项目名称:ESP8266_Basic,代码行数:9,代码来源:WIFI.cpp


示例5: set

String WIFI::set(Topic &topic) {

  if (topic.itemIs(3, "scan")) {
    return scanWifi();
  } else {
    return TOPIC_NO;
  }
}
开发者ID:Pfannex,项目名称:ESP8266_Basic,代码行数:8,代码来源:WIFI.cpp


示例6: get

String customDevice::get(Topic &topic) {
  /*
  ~/get
  └─device             (level 2)
    └─sensor1          (level 3)
  */

  logging.debug("device get topic " + topic.topic_asString());

  if (topic.getItemCount() != 4) // ~/get/device/sensor1
    return TOPIC_NO;
  if (topic.itemIs(3, "sensor1")) {
    return String(measure());
  } else {
    return TOPIC_NO;
  }
}
开发者ID:Pfannex,项目名称:ESP8266_Basic,代码行数:17,代码来源:customDevice.cpp


示例7: set

String customDevice::set(Topic &topic) {
  /*
  ~/set
  └─device             (level 2)
    └─yourItem         (level 3)
  */

  logging.debug("device set topic " + topic.topic_asString() + " to " +
                topic.arg_asString());

  if (topic.getItemCount() != 4) // ~/set/device/yourItem
    return TOPIC_NO;
  if (topic.itemIs(3, "yourItem")) {
    return TOPIC_OK;
  } else {
    return TOPIC_NO;
  }
}
开发者ID:Pfannex,项目名称:ESP8266_Basic,代码行数:18,代码来源:customDevice.cpp


示例8: section_beg

void TXTWriter::renderSectionStart(ostream& out, const string& id)
{
	const string& sectTopicID = m_data->getElementProperty(id, "topic");
	const string& sectDesc = m_data->getElementProperty(id, "desc");

	if ( m_printDetailed )
		out << "/section id=" << id << "/ ";
	out << endl << endl << section_beg() << m_data->getElementProperty(id, "type")	;
	if (sectDesc != "")
		out << " - " << sectDesc;

	if (sectTopicID != "")
	{
		Topic* topic =  Topics::getTopicFromAll(sectTopicID, m_data->conventions().getTopics());
		out << " {" << topic->getLabel() << "} ";
	}

	out << section_end() << endl;
}
开发者ID:eroux,项目名称:transcriber-ag,代码行数:19,代码来源:TXTWriter.cpp


示例9: GetEveryWordInOneTopicByWordProperty

void IsPolitics::GetEveryWordInOneTopicByWordProperty(Topic &onetopic) {
  this->topic_word_size=0;
  this->keyword_map.clear();
//  std::cout<<"mapsize: "<<this->keyword_map.size()<<std::endl;
  std::vector<WeiboWord>::iterator or_it;
  std::list<Weibo>::iterator t_w_it;
  t_w_it = onetopic.GetTopicWeibo()->begin();
  for(;t_w_it != onetopic.GetTopicWeibo()->end();++t_w_it){
    std::vector<WeiboWord> resultword;
    this->SplitWeiboSplit(t_w_it->spilt,resultword);

    or_it = resultword.begin();
    for (; or_it != resultword.end(); ++or_it) {
      onetopic.allweibowordnum++;
      this-> topic_word_size++;
      this->AddKeyToMapWithProperty(*or_it);
    }
  }

}
开发者ID:huntzhan,项目名称:WeiboTopic,代码行数:20,代码来源:IsPolitics.cpp


示例10: Cal_Words_Topic_Distance

/*@input
 * 		Topic:话题
 * 		TopicWord:特征词
 * 计算簇与特征词之间的距离
 */
double Cluster::Cal_Words_Topic_Distance(Topic &topic, TopicWord &topic_word) {
    double topic_word_dis = 0.0;
    std::string keyword = topic_word.GetTopicWord();
    std::map<std::string, double>* map_map;
    std::map<string, CooccurrenceWord>::iterator co_it = co_ccur_matrix.find(keyword);
    if (co_it != co_ccur_matrix.end()) {
        map_map = co_it->second.GetWordCooccurrence();
    } else {
        return 0.0;
    }
    list<TopicWord>::iterator clu_it = topic.GetsTopic()->begin();//这里一定要指针??为什么?
    std::string one_topic_word;
    std::map<std::string, double>::iterator second_it;
    for (; clu_it != topic.GetsTopic()->end(); ++clu_it) {
        one_topic_word = clu_it->GetTopicWord();
        second_it = map_map->find(one_topic_word);
        if (second_it != map_map->end()) {
            topic_word_dis += second_it->second;

        }
    }
    return topic_word_dis / topic.GetsTopic()->size();
}
开发者ID:huntzhan,项目名称:WeiboTopic,代码行数:28,代码来源:Cluster.cpp


示例11: insert

void Tag::insert(Topic& topic) {
  /*
    find the given topic_id with the given last_post_time
    if it exists, remove it
    insert the given topic.
  */
  TopicList::iterator search_iter = _topic_list.find_topic(topic);

  if (search_iter != _topic_list.end() && (*search_iter).time() != topic.time()) {
    _topic_list.erase(search_iter);
    _topic_list.insert(topic);
  } else {
    _topic_list.insert(topic);
  }
}
开发者ID:shaldengeki,项目名称:eti-unofficial-tagd,代码行数:15,代码来源:tag.cpp


示例12: set

String customDevice::set(Topic &topic) {
  /*
  ~/set
  └─device             (level 2)
    └─deviceCFG        (level 3)
    └─index            (level 4) individual setting
    └─value            (level 4) individual setting
    └─scanBus          (level 4) scan 1W-Bus for new devices
*/


  logging.debug("device set topic " + topic.topic_asString() + " to " +
                topic.arg_asString());
  String ret = TOPIC_NO;

  if (topic.itemIs(3, "deviceCFG")) {
    //modify dashboard-------------------
    if (topic.itemIs(4, "addItem")) {
      modifyDashboard();
      return TOPIC_OK;
    }
  }
  return ret;
}
开发者ID:Pfannex,项目名称:ESP8266_Basic,代码行数:24,代码来源:customDevice.cpp


示例13: sw

void Cluster::ListEveryTopicWeiboId(Topic &one_topic) {
    list<TopicWord>::iterator topic_it = one_topic.GetsTopic()->begin();
    std::map<std::string, double> *topic_weibo_id_map =one_topic.GetTopicWeiboId();
    std::map<std::string, double>::iterator topic_weibo_id_map_it;
    one_topic.topic_message_num = 0;


    for (; topic_it != one_topic.GetsTopic()->end(); ++topic_it) {
        std::set<std::string>::iterator topicword_weibolist_it =
            topic_it->GetWordToWeiboidList()->begin();
        for (; topicword_weibolist_it
                != topic_it->GetWordToWeiboidList()->end(); ++topicword_weibolist_it) {
            std::string weiboid = *topicword_weibolist_it;
            topic_weibo_id_map_it = topic_weibo_id_map->find(weiboid);
            if (topic_weibo_id_map_it != topic_weibo_id_map->end()) {
                topic_weibo_id_map_it->second = topic_weibo_id_map_it->second + 1;
            } else {
                topic_weibo_id_map->insert(make_pair(weiboid, 1.0));
            }
        }
    }



    topic_weibo_id_map_it = topic_weibo_id_map->begin();

    for (; topic_weibo_id_map_it != topic_weibo_id_map->end(); ++topic_weibo_id_map_it) {
        if (topic_weibo_id_map_it->second >= this->BELONG_TOPIC_THROD) {
            subword sw(topic_weibo_id_map_it->first,topic_weibo_id_map_it->second);

            one_topic.GetWeiboIdList()->push_back(sw);
            one_topic.topic_message_num += 1;
        }
    }

    one_topic.GetTopicWeiboId()->clear();
    std::sort(one_topic.GetWeiboIdList()->begin(),
              one_topic.GetWeiboIdList()->end(), weibosort);

    //及时清除内存
    if(one_topic.topic_message_num<=this->MIN_TOPIC_MESSAGE_NUM) {
        one_topic.weibo_id_list.clear();
        std::vector<subword>(one_topic.weibo_id_list).swap(one_topic.weibo_id_list);
    }
    //将得出的结果存进数据库
}
开发者ID:huntzhan,项目名称:WeiboTopic,代码行数:46,代码来源:Cluster.cpp


示例14: printMessages

bool MyEventHandler::processEvent(const Event& event, ProviderSession* session)
{
    if (event.eventType() == Event::SESSION_STATUS) {
        printMessages(event);
        MessageIterator iter(event);
        while (iter.next()) {
            Message msg = iter.message();
            if (msg.messageType() == SESSION_TERMINATED) {
                g_running = false;
            }
        }
    }
    else if (event.eventType() == Event::TOPIC_STATUS) {
        TopicList topicList;
        MessageIterator iter(event);
        while (iter.next()) {
            Message msg = iter.message();
            std::cout << msg << std::endl;
            if (msg.messageType() == TOPIC_SUBSCRIBED) {
                std::string topicStr = msg.getElementAsString("topic");
                MutexGuard guard(&g_mutex);
                MyStreams::iterator it = g_streams.find(topicStr);
                if (it == g_streams.end()) {
                    // TopicList knows how to add an entry based on a
                    // TOPIC_SUBSCRIBED message.
                    topicList.add(msg);
                    it = (g_streams.insert(MyStreams::value_type(
                                     topicStr,
                                     new MyStream(topicStr)))).first;
                }
                it->second->setSubscribedState(true);
                if (it->second->isAvailable()) {
                    ++g_availableTopicCount;
                }
            }
            else if (msg.messageType() == TOPIC_UNSUBSCRIBED) {
                std::string topicStr = msg.getElementAsString("topic");
                MutexGuard guard(&g_mutex);
                MyStreams::iterator it = g_streams.find(topicStr);
                if (it == g_streams.end()) {
                    // we should never be coming here. TOPIC_UNSUBSCRIBED can
                    // not come before a TOPIC_SUBSCRIBED or TOPIC_CREATED
                    continue;
                }
                if (it->second->isAvailable()) {
                    --g_availableTopicCount;
                }
                it->second->setSubscribedState(false);
            }
            else if (msg.messageType() == TOPIC_CREATED) {
                std::string topicStr = msg.getElementAsString("topic");
                MutexGuard guard(&g_mutex);
                MyStreams::iterator it = g_streams.find(topicStr);
                if (it == g_streams.end()) {
                    it = (g_streams.insert(MyStreams::value_type(
                                     topicStr,
                                     new MyStream(topicStr)))).first;
                }
                try {
                    Topic topic = session->getTopic(msg);
                    it->second->setTopic(topic);
                } catch (blpapi::Exception &e) {
                    std::cerr
                        << "Exception in Session::getTopic(): "
                        << e.description()
                        << std::endl;
                    continue;
                }
                if (it->second->isAvailable()) {
                    ++g_availableTopicCount;
                }
            }
            else if (msg.messageType() == TOPIC_RECAP) {
                // Here we send a recap in response to a Recap request.
                try {
                    std::string topicStr = msg.getElementAsString("topic");
                    MyStreams::iterator it = g_streams.find(topicStr);
                    MutexGuard guard(&g_mutex);
                    if (it == g_streams.end() || !it->second->isAvailable()) {
                        continue;
                    }
                    Topic topic = session->getTopic(msg);
                    Service service = topic.service();
                    CorrelationId recapCid = msg.correlationId();

                    Event recapEvent = service.createPublishEvent();
                    EventFormatter eventFormatter(recapEvent);
                    eventFormatter.appendRecapMessage(topic, &recapCid);
                    eventFormatter.setElement("numRows", 25);
                    eventFormatter.setElement("numCols", 80);
                    eventFormatter.pushElement("rowUpdate");
                    for (int i = 1; i < 6; ++i) {
                        eventFormatter.appendElement();
                        eventFormatter.setElement("rowNum", i);
                        eventFormatter.pushElement("spanUpdate");
                        eventFormatter.appendElement();
                        eventFormatter.setElement("startCol", 1);
                        eventFormatter.setElement("length", 10);
                        eventFormatter.setElement("text", "RECAP");
                        eventFormatter.popElement();
//.........这里部分代码省略.........
开发者ID:AbhiAgarwal,项目名称:context,代码行数:101,代码来源:PagePublisherExample.cpp


示例15: printf

/*-------------------------------------------------------
                Upstream MQTTSnSubscribe
 -------------------------------------------------------*/
void GatewayControlTask::handleSnSubscribe(Event* ev, ClientNode* clnode, MQTTSnMessage* msg){
	printf(FORMAT2, currentDateTime(), "SUBSCRIBE", LEFTARROW, clnode->getNodeId()->c_str(), msgPrint(msg));

	MQTTSnSubscribe* sSubscribe = new MQTTSnSubscribe();
	MQTTSubscribe* subscribe = new MQTTSubscribe();
	sSubscribe->absorb(msg);

	uint8_t topicIdType = sSubscribe->getFlags() & 0x03;

	subscribe->setMessageId(sSubscribe->getMsgId());

	if(sSubscribe->getFlags() & MQTTSN_FLAG_DUP ){
		subscribe->setDup();
	}
	if(sSubscribe->getFlags() & MQTTSN_FLAG_RETAIN){
		subscribe->setRetain();
	}
	subscribe->setQos(sSubscribe->getQos());

	if(topicIdType != MQTTSN_FLAG_TOPICID_TYPE_RESV){
		if(topicIdType == MQTTSN_FLAG_TOPICID_TYPE_PREDEFINED){
			/*----- Predefined TopicId ------*/
			MQTTSnSubAck* sSuback = new MQTTSnSubAck();

			if(sSubscribe->getMsgId()){       // MessageID
				sSuback->setQos(sSubscribe->getQos());
				sSuback->setTopicId(sSubscribe->getTopicId());
				sSuback->setMsgId(sSubscribe->getMsgId());

				if(sSubscribe->getTopicId() == MQTTSN_TOPICID_PREDEFINED_TIME){
					sSuback->setReturnCode(MQTT_RC_ACCEPTED);
				}else{
					sSuback->setReturnCode(MQTT_RC_REFUSED_IDENTIFIER_REJECTED);
				}

				clnode->setClientSendMessage(sSuback);

				Event* evsuback = new Event();
				evsuback->setClientSendEvent(clnode);
				printf(FORMAT1, currentDateTime(), "SUBACK", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(sSuback));

				_res->getClientSendQue()->post(evsuback);
			}

			if(sSubscribe->getTopicId() == MQTTSN_TOPICID_PREDEFINED_TIME){

				MQTTSnPublish* pub = new MQTTSnPublish();
				pub->setTopicIdType(1);  // pre-defined
				pub->setTopicId(MQTTSN_TOPICID_PREDEFINED_TIME);
				pub->setMsgId(clnode->getNextSnMsgId());

				uint8_t buf[4];
				uint32_t tm = time(0);
				setUint32(buf,tm);

				pub->setData(buf, 4);
				printf(GREEN_FORMAT1, currentDateTime(), "PUBLISH", RIGHTARROW, clnode->getNodeId()->c_str(), msgPrint(pub));

				clnode->setClientSendMessage(pub);

				Event *evpub = new Event();
				evpub->setClientSendEvent(clnode);
				_res->getClientSendQue()->post(evpub);
			}
			delete subscribe;
		}else{
			uint16_t tpId;

			Topic* tp = clnode->getTopics()->getTopic(sSubscribe->getTopicName());
			if (tp){
				tpId = tp->getTopicId();
			}else{
				tpId = clnode->getTopics()->createTopic(sSubscribe->getTopicName());
			}

			subscribe->setTopic(sSubscribe->getTopicName(), sSubscribe->getQos());
			if(sSubscribe->getMsgId()){
				MQTTSnSubAck* sSuback = new MQTTSnSubAck();
				sSuback->setMsgId(sSubscribe->getMsgId());
				sSuback->setTopicId(tpId);
				clnode->setWaitedSubAck(sSuback);
			}

			clnode->setBrokerSendMessage(subscribe);
			Event* ev1 = new Event();
			ev1->setBrokerSendEvent(clnode);
			_res->getBrokerSendQue()->post(ev1);
			delete sSubscribe;
			return;
		}

	}else{
		/*-- Irregular TopicIdType --*/
		if(sSubscribe->getMsgId()){
			MQTTSnSubAck* sSuback = new MQTTSnSubAck();
			sSuback->setMsgId(sSubscribe->getMsgId());
			sSuback->setTopicId(sSubscribe->getTopicId());
//.........这里部分代码省略.........
开发者ID:comrit,项目名称:MQTT-SN,代码行数:101,代码来源:GatewayControlTask.cpp


示例16: ofSetWindowShape

//--------------------------------------------------------------
void ofApp::setup(){

    ofSetWindowShape(800, 1000);
    ofPoint chartPos = ofPoint(ofGetWidth() * 0.1, ofGetHeight() * 0.1);
    ofPoint chartSize = ofPoint(ofGetWidth() * 0.8, ofGetHeight() * 0.8);
    drawLabels = true;
    chartType = 0;
    
    // 0: Load tsv file
    ofBuffer file = ofBufferFromFile("pomodoro.tsv");
    
    // 1: Get all possible dates
    vector<string> allDates;
    string prevDate = "";
    while (!file.isLastLine()){
        string line = file.getNextLine();
        vector <string> split = ofSplitString(line, "\t");
        string thisDate = split[0];
        
        if(thisDate != prevDate){
            allDates.push_back(thisDate);
        }
        prevDate = thisDate;
    }
    
    // 2: Create topics with names and pass all possible dates
    file.resetLineReader();
    while (!file.isLastLine()){
        string line = file.getNextLine();
        vector <string> split = ofSplitString(line, "\t");
        string thisName = split[1];
        
        bool nameIsStored = false;
        
        for (int i = 0; i < allTopics.size(); i++) {
            
            if(allTopics[i].name == thisName){
                
                nameIsStored = true;
            }
        }
        
        if(!nameIsStored){
            Topic thisTopic;
            thisTopic.setup(thisName, allDates);
            allTopics.push_back(thisTopic);
        }
    }

    // 3: Fill out hours
    file.resetLineReader();
    while (!file.isLastLine()){
        string line = file.getNextLine();
        vector <string> split = ofSplitString(line, "\t");
        string thisName = split[1];
        string thisDate = split[0];
        float theseHours = split[5].size() * 0.5;

        for (int i = 0; i < allTopics.size(); i++) {

            if(allTopics[i].name == thisName){

                for (int j = 0; j < allTopics[i].dates.size(); j++){

                    if (allTopics[i].dates[j] == thisDate) {

                        allTopics[i].hours[j] += theseHours;
                    }
                }
            }
        }
    }
    
    // 4: Calculate the total hours for each topic
    for (int i = 0; i < allTopics.size(); i++) {
        allTopics[i].calculateHours();
    }

    // 5: Sort by total hours
    sort(allTopics.begin(), allTopics.end(), sortByCount);
    
    // 6: Before setting the vertices, we need to know
    // what is the highest value of hours for one day
    vector<float> allHours;
    for (int i = 0; i < allTopics[0].hours.size(); i++) {
        float sumOfHours = 0.0;
        for (int j = 0; j < allTopics.size(); j++) {
//            cout << allTopics[j].hours[i] << endl;
            sumOfHours += allTopics[j].hours[i];
        }
//        cout << "****************************" << endl;
//        cout << sumOfHours << endl;
//        cout << "****************************" << endl;
        allHours.push_back(sumOfHours);
    }
    float maxHoursPerDay = 0.0;
    for (int i = 0; i < allHours.size(); i++) {
//        cout << allHours[i] << endl;
        if (allHours[i] > maxHoursPerDay) {
//.........这里部分代码省略.........
开发者ID:gianordoli,项目名称:printmaking,代码行数:101,代码来源:ofApp.cpp


示例17: while

void Camera::DetectSatellite() {
	int horizontalLine[WIDTH];
	int verticalLine[HEIGHT];

	// Init Arrays
	for (int x = 0; x < WIDTH; x++) {
		horizontalLine[x] = 0;
	}
	for (int y = 0; y < HEIGHT; y++) {
		verticalLine[y] = 0;
	}

	int pixel = 0;
	// Sum up Picture to Lines
	for (int y = 0; y < HEIGHT; y++) {
		for (int x = 0; x < WIDTH; x++) {
			if ((int) DCMI_Buffer[2 * x + 2 * y * WIDTH] > THRESHOLD) {
				horizontalLine[x] += (int) DCMI_Buffer[2 * x + 2 * WIDTH * y];
				verticalLine[y] += (int) DCMI_Buffer[2 * x + 2 * WIDTH * y];
				pixel++;
			}
		}
	}

	if(pixel<MINPIXELTHRESHOLD) { //Cancel if object is too small
		target.x=0;
		target.y=0;
		return;
	}

    // Find the position in the arrays where the sumed up values
	// are Q1, HALF and Q3 of the overall sum. HALF is exactly
	// the center of gravity of the picture, the span between
	// Q1 and Q3 is a good indicatior for the angle of the obj.
    int counter = 0;
    int sum1 = 0;
    int sum2 = 0;
    for(int x = 0; x < WIDTH; x++) {
        sum1 += horizontalLine[x];
    }
    int first_quarter = 0;
    int third_quarter = 0;
    int targetX = 0;
    int spanX = 0;
    while(sum2<Q3*sum1) {
        sum2 += horizontalLine[counter];
        counter++;
        if((Q1*sum1<sum2)&&(first_quarter==0)){
            first_quarter = counter;
        }
        if((HALF*sum1<sum2)&&(targetX==0)) {
            targetX = counter;
        }
        if((Q3*sum1<sum2)&&(third_quarter==0)) {
            third_quarter = counter;
        }
    }
    spanX = third_quarter - first_quarter;

    counter = 0;
    sum1 = 0;
    sum2 = 0;
    for(int y = 0; y < HEIGHT; y++) {
        sum1 += verticalLine[y];
    }
    first_quarter = 0;
    third_quarter = 0;
    int targetY = 0;
    int spanY = 0;
    while(sum2<Q3*sum1) {
        sum2 += verticalLine[counter];
        counter++;
        if((Q1*sum1<sum2)&&(first_quarter==0)){
            first_quarter = counter;
        }
        if((HALF*sum1<sum2)&&(targetY==0)) {
            targetY = counter;
        }
        if((Q3*sum1<sum2)&&(third_quarter==0)) {
            third_quarter = counter;
        }
    }
    spanY = third_quarter - first_quarter;
    // ----------------------------------

    bool fireAngle = spanX>2*spanY;
	target.y = targetX;
	target.x = targetY;
	cameraTargetTopic.publish(target);
	cameraFireTopic.publish(fireAngle);
	xprintf("Target: x:%d, y:%d\n", target.x, target.y);
	xprintf("Fire: %d\n", fireAngle);
	// ---------------------------------
}
开发者ID:hellno,项目名称:FloatSat,代码行数:94,代码来源:Camera.cpp


示例18: main

int main(int argc, char *argv[]) {
  try {
    BaseTestCase::startTest(argv);
    // create Admin and connect
    XoramAdmin* admin = new XoramAdmin();
    admin->connect("root", "root", 60);

    // create destination
    Queue* queue = admin->createQueue("queue");
    printf("queue->getUID() = %s, queue->getName() = %s\n",queue->getUID(), queue->getName());
    Topic* topic = admin->createTopic("topic");
    printf("topic->getUID() = %s, topic->getName() = %s\n",topic->getUID(), topic->getName());

    // set right
    admin->setFreeReading(queue);
    admin->setFreeWriting(queue);
    admin->setFreeReading(topic);
    admin->setFreeWriting(topic);

    // create "anonymous" user
    admin->createUser("anonymous", "anonymous");

    ConnectionFactory* cf = new TCPConnectionFactory("localhost", 16010);
    Connection* cnx = cf->createConnection("anonymous", "anonymous");
    cnx->start();
    Session* sess = cnx->createSession();
    MessageProducer* prod1 = sess->createProducer(queue);
    MessageProducer* prod2 = sess->createProducer(topic);
    MessageConsumer* cons1 = sess->createConsumer(queue);
    MessageConsumer* cons2 = sess->createConsumer(topic);

    Message* msg1 = sess->createMessage();
    prod1->send(msg1);
    printf("##### Message sent on queue: %s\n", msg1->getMessageID());

    Message* msg2 = sess->createMessage();
    prod2->send(msg2);
    printf("##### Message sent on topic: %s\n", msg2->getMessageID());
    
    Message* msg = cons1->receive();
    printf("##### Message received from queue: %s\n", msg->getMessageID());

    msg = cons2->receive();
    printf("##### Message received from tpoic: %s\n", msg->getMessageID());
    
    // delete User
    CreateUserReply* userReply = admin->createUser("removeUser", "removeUser");
    admin->deleteUser("removeUser",userReply->getProxId());

    // delete Queue and Topic
    printf("delete Queue %s\n", queue->getUID());
    admin->deleteDestination(queue->getUID());
    printf("delete Topic %s\n", topic->getUID());
    admin->deleteDestination(topic->getUID());

    admin->disconnect();

    cnx->close();

} catch (Exception exc) {
    printf("##### exception - %s", exc.getMessage());
    BaseTestCase::error(&exc);
  } catch (...) {
    printf("##### exception\n");
    BaseTestCase::error(new Exception(" catch ..., unknown exception "));
  }
  printf("##### bye\n");
  BaseTestCase::endTest();
}
开发者ID:okse-2,项目名称:joram,代码行数:69,代码来源:TestXoramAdmin.C


示例19: call

String Controller::call(Topic &topic) {

  // MQTT state information via API-call
  if (topic.modifyTopic(0) == "event/mqtt/connected") {
    if (topic.argIs(0, "1")) {
      on_mqtt_connected();
    } else {
      on_mqtt_disconnected();
    }
  }

  // D("Controller: begin call");
  // set
  if (topic.itemIs(1, "set")) {
    if (topic.itemIs(2, "ffs")) {
      return ffs.set(topic);
    } else if (topic.itemIs(2, "clock")) {
      return clock.set(topic);
    } else if (topic.itemIs(2, "esp")) {
      return espTools.set(topic);
    } else if (topic.itemIs(2, "wifi")) {
      return wifi.set(topic);
    } else if (topic.itemIs(2, "device")) {
      if (topic.itemIs(3, "fillDashboard")) {
        return device.fillDashboard();
      } else {
        return device.set(topic);
      }
    } else if (topic.itemIs(2, "controller")) {
      if (topic.itemIs(3, "reconnectDelay")) {
        D("set reconnectDelay");
        Di("arg=", topic.getArgAsLong(0));
        reconnectDelay = topic.getArgAsLong(0);
        if (reconnectDelay < 1)
          reconnectDelay = 1;
        if (reconnectDelay > RECONNECT_DELAY_MAX)
          reconnectDelay = RECONNECT_DELAY_MAX;
        reconnectDelayed = 0;
        return TOPIC_OK;
      } else {
        return TOPIC_NO;
      }
    } else {
      return TOPIC_NO;
    }
    // get
  } else if (topic.itemIs(1, "get")) {
    if (topic.itemIs(2, "ffs")) {
      return ffs.get(topic);
    } else if (topic.itemIs(2, "clock")) {
      return clock.get(topic);
    } else if (topic.itemIs(2, "esp")) {
      return espTools.get(topic);
    } else if (topic.itemIs(2, "wifi")) {
      return wifi.get(topic);
    } else if (topic.itemIs(2, "device")) {
      if(topic.itemIs(3, "flags")) {
        return fwConfig();
      } else if(topic.itemIs(3, "version")) {
        return device.getVersion();
      } else if (topic.itemIs(3, "type")) {
        return device.getType();
      } else if (topic.itemIs(3, "dashboard")) {
        return device.getDashboard();
      } else {
        return device.get(topic);
      }
    } else {
      return TOPIC_NO;
    }
  } else {
    return TOPIC_NO;
  }
  // D("Controller: end call");
}
开发者ID:Pfannex,项目名称:ESP8266_Basic,代码行数:75,代码来源:Controller.cpp


示例20: time

/*
 * @description:
 *  一趟聚类的思想
 */
void Cluster::Singlepass() {
#ifdef TIME
    time_t start3;
    start3 = time(NULL);
#endif


    this->SetClusterThrod(this->GenClusterThrod() + THROD_ADD);
    std::cout << "CLUSTER_THROD: " << this->CLSTER_THROD << std::endl;

#ifdef DEBUG_CLUSTER1
    printMatrix(this->co_ccur_matrix);
#endif

    MAP::iterator topic_w_it = this->topicword->begin();
    TopicWord firstword = topic_w_it->second;
    //这里初始化一个词作为一个簇(topic)
    Topic topic;
    topic.TopicInit(firstword);
    this->clusterList.push_back(topic);

    //对于每一个词,计算词在话题列表Topic的距离
    topic_w_it++;
    std::cout<<"聚类前特征词的个数"<<this->topicword->size()<<std::endl;
    for (; topic_w_it != this->topicword->end(); ++topic_w_it) {

        vector<Topic>::iterator vec_clu_it = this->clusterList.begin();
        double maxDistance = MINVALUE;
        vector<Topic>::iterator belong_clus_it = vec_clu_it;//这里应该是赋值还是指针????
        for (; vec_clu_it != this->clusterList.end(); ++vec_clu_it) {
            double words_distance = Cal_Words_Topic_Distance(*vec_clu_it,topic_w_it->second);
            //查看是否有比之前保留的最近的簇更近的簇
            if (maxDistance < words_distance) {
                maxDistance = words_distance;
                belong_clus_it = vec_clu_it;
            }
        }
        //如果该词与该簇距离最近,那么将该词加入该簇
        if (maxDistance < this->CLSTER_THROD) {
            Topic newTopic;
            newTopic.TopicInit(topic_w_it->second);
            this->clusterList.push_back(newTopic);
        } else {
            belong_clus_it->addTopicWord(topic_w_it->second);
        }
    }


#ifdef TIME
    time_t ends4;
    ends4 = time(NULL);
    std::cout << "一趟聚类用时:" << difftime(ends4, start3) << std::endl;
#endif

#ifdef TIME
    time_t start5;
    start5 = time(NULL);
#endif
    //及时将共现矩阵清空
//	this->co_ccur_matrix.clear();
    //match weibo id to topic
    this->MatchWeiboIDToTopic();
    //select the weibo which have more than two words in topic
    this->ListAllTopicWeiboId();

#ifdef TIME
    time_t ends5;
    ends5 = time(NULL);
    std::cout << "微博对应话题用时:" << difftime(ends5, start5) << std::endl;
#endif


    this->SortTopic();
//	this->InsterAllTopicToDatabase();


#ifdef PRINTTOPICA
    printTopic(&this->clusterList);
#endif
}
开发者ID:huntzhan,项目名称:WeiboTopic,代码行数:84,代码来源:Cluster.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TopicPrx类代码示例发布时间:2022-05-31
下一篇:
C++ Topend类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap