std::shared_ptr<BaseInformationStream> StreamStore::registerBaseStream( std::string dataType, std::shared_ptr<InformationSpecification> specification, const std::string name, const int streamSize, std::map<std::string, int> metadata, std::string provider, std::string sourceSystem) { auto ptr = this->getBaseStream(specification.get(), provider, sourceSystem); //stream already registered if (ptr) { _log->warn("Duplicated Stream with '%v', '%v', '%v'", specification->toString(), provider, sourceSystem); return ptr; } auto desc = std::make_shared<StreamDescription>(specification, name, provider, sourceSystem, metadata); std::string type = this->ontology->toLongIri(dataType); auto stream = this->streamFactory->createStream(type, desc, this->eventHandler, streamSize); if (stream) { _log->debug("Created stream with '%v', '%v', '%v', '%v'", specification->toString(), provider, sourceSystem, type); this->streams.push_back(stream); } else { _log->error("Stream with '%v', '%v', '%v', '%v' could not be created", specification->toString(), provider, sourceSystem, type); } return stream; }
void CommunicationInterface::onRequestInformation(std::shared_ptr<Entity> const &entity, std::vector<std::shared_ptr<InformationSpecification>> const &requests) { _log->info("Information request received from '%v'", entity->toString()); std::vector<std::shared_ptr<InformationElement<GContainer>>> infos; for (auto &request : requests) { this->bridge->informationStore->getInformation(request,infos); } int count = infos.size(); if (count == 0) { _log->warn("No information found for request from '%v'", entity->toString()); return; } _log->info("Sending '%v' information to '%v'", count, entity->toString()); for (auto &info : infos) { auto m = std::make_shared<InformationMessage>(); m->setEntity(entity); m->getInformations().push_back(info); this->sendMessage(m); } }
int main(int argc, char* argv[]) { std::string tmp(argv[1]); std::istringstream input(tmp); const std::shared_ptr<const AjucLispParser::Expression> e = AjucLispParser::parse(input); std::cout << e->toString() << std::endl; return 0; }
void CommunicationInterface::requestOffers(std::shared_ptr<Entity> const &entity) { _log->info("Requesting offered information from '%v'", entity->toString()); auto m = std::make_shared<CommandMessage>(IceCmd::SCMD_OFFERS_REQUEST); m->setEntity(entity); this->pushMessage(m); }
/* This function subscribes to all action events from the inputhandler class. It sends the events over serial comm to the server. */ void dtn::GameClient::sendString(std::shared_ptr<dtn::Event> e) { sf::Packet packet; std::string str = e->toString(); std::size_t t = str.length(); packet << str; m_socket.send(packet); }
void STidSTRReaderUnitConfiguration::setHMACKey(std::shared_ptr<HMAC1Key> key) { if (key) { LOG(LogLevel::DEBUGS) << "Set HMAC key data {" << key->toString() << "}"; d_key_hmac = key; } }
void STidSTRReaderUnitConfiguration::setAESKey(std::shared_ptr<AES128Key> key) { if (key) { LOG(LogLevel::DEBUGS) << "Set AES 128 key data {" << key->toString() << "}"; d_key_aes = key; } }
void CommunicationInterface::onRequestIds(std::shared_ptr<Entity> const &entity) { _log->info("Sending Ids to '%v'", entity->toString()); auto m = std::make_shared<IdMessage>(); m->setEntity(entity); this->self->pushIds(m->getIds()); this->pushMessage(m); }
void saveXMLFile(std::shared_ptr<XMLElement> rootElement, const char *filename, const char *dtdFilename) { assert(filename != nullptr); assert(rootElement.get() != nullptr); ofstream file(filename, ios::out | ios::trunc); file << "<?xml version=\"1.0\"?>" << endl; if (dtdFilename != nullptr) { file << "<!DOCTYPE " << rootElement->name() << " SYSTEM \"" << dtdFilename << "\">" << std::endl; } file << rootElement->toString(); }
void CommunicationInterface::onInformation(std::shared_ptr<Entity> const &entity, std::vector<std::shared_ptr<InformationElement<GContainer>>> &information) { _log->info("Information received from '%v'", entity->toString()); for (auto &info : information) { this->informationStore->addInformation(info); } }
void CommunicationInterface::onRequestOffers(std::shared_ptr<Entity> const &entity) { _log->info("Sending offered information to '%v'", entity->toString()); auto m = std::make_shared<OffersMessage>(); m->setEntity(entity); auto &vec = m->getOfferes(); for (auto info : this->bridge->getOfferedInfos()) { vec.push_back(info->infoSpec); } this->pushMessage(m); }
void CommunicationInterface::requestInformation(std::shared_ptr<Entity> const &entity, std::vector<std::shared_ptr<InformationSpecification>> const &requests) { _log->info("Requesting information from '%v'", entity->toString()); auto m = std::make_shared<RequestMessage>(); m->setEntity(entity); auto &vec = m->getRequests(); for (auto info : requests) { vec.push_back(info); } this->pushMessage(m); }
void terrama2::core::erasePreviousResult(DataManagerPtr dataManager, DataSeriesId dataSeriesId, std::shared_ptr<te::dt::TimeInstantTZ> startTime) { auto outputDataSeries = dataManager->findDataSeries(dataSeriesId); if(!outputDataSeries) { TERRAMA2_LOG_ERROR() << QObject::tr("Invalid output data series for analysis."); return; } auto outputDataProvider = dataManager->findDataProvider(outputDataSeries->dataProviderId); if(!outputDataProvider) { TERRAMA2_LOG_ERROR() << QObject::tr("Invalid output data provider for analysis."); return; } if(outputDataProvider->dataProviderType == "POSTGIS") { auto dataset = outputDataSeries->datasetList[0]; std::string tableName = getTableNameProperty(dataset); std::shared_ptr<te::da::DataSource> datasource(te::da::DataSourceFactory::make("POSTGIS", outputDataProvider->uri)); // RAII for open/closing the datasource terrama2::core::OpenClose<std::shared_ptr<te::da::DataSource> > openClose(datasource); if(!datasource->isOpened()) { QString errMsg = QObject::tr("DataProvider could not be opened."); TERRAMA2_LOG_ERROR() << errMsg; throw Exception() << ErrorDescription(errMsg); } // get a transactor to interact to the data source std::shared_ptr<te::da::DataSourceTransactor> transactor(datasource->getTransactor()); auto dataSetNames = transactor->getDataSetNames(); if(std::find(dataSetNames.cbegin(), dataSetNames.cend(), tableName) != dataSetNames.cend() || std::find(dataSetNames.cbegin(), dataSetNames.cend(), "public."+tableName) != dataSetNames.cend()) transactor->execute("delete from " + tableName + " where execution_date = '" + startTime->toString() + "'"); } else { QString errMsg = QObject::tr("Removing old results not implement for this dataseries format."); TERRAMA2_LOG_ERROR() << errMsg; } }
std::shared_ptr<Value> clone(std::shared_ptr<const Value> v) { if (not v) return std::shared_ptr<Value>(); switch (v->getType()) { case Value::INTEGER: return std::static_pointer_cast<Value>( std::make_shared<Integer>(v->toInteger())); case Value::BOOLEAN: return std::static_pointer_cast<Value>( std::make_shared<Boolean>(v->toBoolean())); case Value::DOUBLE: return std::static_pointer_cast<Value>( std::make_shared<Double>(v->toDouble())); case Value::STRING: return std::static_pointer_cast<Value>( std::make_shared<String>(v->toString())); case Value::SET: return std::static_pointer_cast<Value>( std::make_shared<Set>(v->toSet())); case Value::MAP: return std::static_pointer_cast<Value>( std::make_shared<Map>(v->toMap())); case Value::TUPLE: return std::static_pointer_cast<Value>( std::make_shared<Tuple>(v->toTuple())); case Value::TABLE: return std::static_pointer_cast<Value>( std::make_shared<Table>(v->toTable())); case Value::XMLTYPE: return std::static_pointer_cast<Value>( std::make_shared<Xml>(v->toXml())); case Value::NIL: return std::static_pointer_cast<Value>( std::make_shared<Null>(v->toNull())); case Value::MATRIX: return std::static_pointer_cast<Value>( std::make_shared<Matrix>(v->toMatrix())); case Value::USER: return std::shared_ptr<Value>(); } return std::shared_ptr<Value>(); }
static void Validate(const std::shared_ptr<const PlanType> &plan) { if (plan->getNumChildren() > 0) { const std::vector<expressions::AttributeReferencePtr> referenced_attributes = plan->getReferencedAttributes(); std::vector<expressions::AttributeReferencePtr> visible_attributes; for (const std::shared_ptr<const PlanType> &child : plan->children()) { Validate<PlanType>(child); const std::vector<expressions::AttributeReferencePtr> input_attributes = child->getOutputAttributes(); visible_attributes.insert(visible_attributes.end(), input_attributes.begin(), input_attributes.end()); } for (const expressions::AttributeReferencePtr &referenced_attribute : referenced_attributes) { CHECK(expressions::ContainsExpression(visible_attributes, referenced_attribute)) << "\nDangling attribute reference " << referenced_attribute->getShortString() << " in the plan:\n" << plan->toString(); } } }
void terrama2::core::ProcessLogger::result(Status status, const std::shared_ptr<te::dt::TimeInstantTZ> &dataTimestamp, RegisterId registerId) const { if(!isValid_) throw terrama2::core::LogException() << ErrorDescription("Error on log!"); if(tableName_.empty()) { QString errMsg = QObject::tr("Can not find log table name"); TERRAMA2_LOG_ERROR() << errMsg; throw terrama2::core::LogException() << ErrorDescription(errMsg); } boost::format query("UPDATE "+ tableName_ + " SET status=%1%, data_timestamp=%2%, last_process_timestamp='%3%' WHERE id =" + QString::number(registerId).toStdString()); QString timestamp = "NULL"; if(dataTimestamp != nullptr) { verify::date(dataTimestamp); auto boostTime = dataTimestamp->getTimeInstantTZ(); timestamp = QString::fromStdString(dataTimestamp->toString()); timestamp.prepend("'"); timestamp.append("'"); } query.bind_arg(1, static_cast<int>(status)); query.bind_arg(2, timestamp); query.bind_arg(3, TimeUtils::nowUTC()->toString()); std::shared_ptr< te::da::DataSourceTransactor > transactor = dataSource_->getTransactor(); transactor->execute(query.str()); transactor->commit(); }
void print_myobject2_2(std::shared_ptr<MyObject2> obj) { std::cout << obj->toString() << std::endl; }
void print_myobject2_3(const std::shared_ptr<MyObject2> &obj) { std::cout << obj->toString() << std::endl; }
std::shared_ptr<ScheduledFuture> ScheduledMessageService::schedule(std::shared_ptr<ActorMessage> msg, unsigned long delay) { DLOG_IF(FATAL, (msg->getDestMemberId() == idgs::pb::UNKNOWN_MEMBER || msg->getSourceMemberId() == idgs::pb::UNKNOWN_MEMBER)) << "Unknown member: " << msg->toString(); std::shared_ptr<ScheduledFuture> result(new ScheduledFuture(msg, sys::getCurrentTime() + delay)); PendingFuturesType& pFuture = tasks[delay]; if (!pFuture.get()) { pFuture.reset(new PendingFutures()); } pFuture->queue.push(result); return result; }
void print_myobject3_3(const std::shared_ptr<MyObject3> &obj) { py::print(obj->toString()); }
void print_myobject3_2(std::shared_ptr<MyObject3> obj) { py::print(obj->toString()); }
void Device::receiveFrame(std::shared_ptr<Frame> frame, int interfaceId, int portId) { frame->setInterfaceId(interfaceId); frame->setPortId(portId); qDebug() << frame->toString().c_str(); addFrameToHistory(frame); }