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


C++ Topic类代码示例

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


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


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