本文整理汇总了C++中Mapper类的典型用法代码示例。如果您正苦于以下问题:C++ Mapper类的具体用法?C++ Mapper怎么用?C++ Mapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv) {
size_t len = rand() % 200;
uint maxv = 50 + rand() % 50;
Array a(len,maxv);
for(uint i=0;i<len;i++) {
a.setField(i,rand()%maxv);
}
Mapper * mapper = new MapperCont(a, BitSequenceBuilderRG(20));
Mapper * mapper2 = new MapperNone();
mapper->use();
mapper2->use();
cout << "Test 1 : Wavelet tree with pointers" << endl;
/*WaveletTree wt1(a,new wt_coder_huff(a, mapper),new BitSequenceBuilderDArray(), mapper);*/
WaveletTree wt1(a,new wt_coder_binary(a, mapper),new BitSequenceBuilderRG(20), mapper);
cout << "bs.size() = " << wt1.getSize() << endl;
testQuantileWT(a, wt1);
cout << "Test 2 : Wavelet tree without pointers" << endl;
WaveletTreeNoptrs wt3(a, new BitSequenceBuilderRRR(32), mapper);
cout << "bs.size() = " << wt3.getSize() << endl;
testQuantileWTNPTR(a, wt3);
mapper->unuse();
mapper2->unuse();
fprintf(stdout,"ALL OK\n");
return 0;
}
示例2: output
void
Master::distributeSynapses(const Mapper& mapper, const network::Generator& net)
{
typedef std::vector<Synapse> svector;
svector input; // dummy
std::vector<svector> output(m_world.size());
unsigned queued = 0;
//! \todo pass this in
const unsigned bufferSize = 2 << 11;
for(network::synapse_iterator s = net.synapse_begin(); s != net.synapse_end(); ++s, ++queued) {
int sourceRank = mapper.rankOf(s->source);
int targetRank = mapper.rankOf(s->target());
output.at(sourceRank).push_back(*s);
if(sourceRank != targetRank) {
output.at(targetRank).push_back(*s);
}
if(queued == bufferSize) {
flushBuffer(SYNAPSE_VECTOR, input, output, m_world);
queued = 0;
}
}
flushBuffer(SYNAPSE_VECTOR, input, output, m_world);
int tag = SYNAPSES_END;
broadcast(m_world, tag, MASTER);
}
示例3:
/*!
\brief
Called by the vtkMitkRenderProp in order to start MITK rendering process.
*/
int mitk::VtkPropRenderer::Render(mitk::VtkPropRenderer::RenderType type)
{
// Do we have objects to render?
if (this->GetEmptyWorldGeometry())
return 0;
if (m_DataStorage.IsNull())
return 0;
// Update mappers and prepare mapper queue
if (type == VtkPropRenderer::Opaque)
this->PrepareMapperQueue();
// go through the generated list and let the sorted mappers paint
for (auto it = m_MappersMap.cbegin(); it != m_MappersMap.cend(); it++)
{
Mapper *mapper = (*it).second;
mapper->MitkRender(this, type);
}
// Render text
if (type == VtkPropRenderer::Overlay)
{
if (m_TextCollection.size() > 0)
{
m_TextRenderer->SetViewport(this->GetVtkRenderer()->GetViewport());
for (auto it = m_TextCollection.begin(); it != m_TextCollection.end(); ++it)
m_TextRenderer->AddViewProp((*it).second);
m_TextRenderer->Render();
}
}
return 1;
}
示例4: if
/*!
\brief
Called by the vtkMitkRenderProp in order to start MITK rendering process.
*/
int mitk::VtkPropRenderer::Render(mitk::VtkPropRenderer::RenderType type)
{
// Do we have objects to render?
if ( this->GetEmptyWorldGeometry())
return 0;
if ( m_DataStorage.IsNull())
return 0;
// Update mappers and prepare mapper queue
if (type == VtkPropRenderer::Opaque)
this->PrepareMapperQueue();
//go through the generated list and let the sorted mappers paint
bool lastVtkBased = true;
//bool sthVtkBased = false;
for(MappersMapType::iterator it = m_MappersMap.begin(); it != m_MappersMap.end(); it++)
{
Mapper * mapper = (*it).second;
VtkMapper* vtkmapper = dynamic_cast<VtkMapper*>(mapper);
if(vtkmapper)
{
//sthVtkBased = true;
if(!lastVtkBased)
{
Disable2DOpenGL();
lastVtkBased = true;
}
}
else if(lastVtkBased)
{
Enable2DOpenGL();
lastVtkBased = false;
}
mapper->MitkRender(this, type);
}
this->UpdateOverlays();
if (lastVtkBased == false)
Disable2DOpenGL();
// Render text
if (type == VtkPropRenderer::Overlay)
{
if (m_TextCollection.size() > 0)
{
m_TextRenderer->SetViewport( this->GetVtkRenderer()->GetViewport() );
for (TextMapType::iterator it = m_TextCollection.begin(); it != m_TextCollection.end() ; it++)
m_TextRenderer->AddViewProp((*it).second);
m_TextRenderer->Render();
}
}
return 1;
}
示例5: solveGenerique
int
solveGenerique(diet_profile_t* pb) {
std::string authKey;
std::string machineId;
std::string optionValueSerialized;
std::string listSerialized = "";
//IN Parameters
diet_string_get(pb,0, authKey);
diet_string_get(pb,1, machineId);
diet_string_get(pb,2, optionValueSerialized);
// reset profile to handle result
diet_profile_reset(pb, 2);
QueryParameters* options = NULL;
List* list = NULL;
try {
//To parse the object serialized
if (! vishnu::parseEmfObject(optionValueSerialized, options)) {
throw TMSVishnuException(ERRCODE_INVALID_PARAM);
}
QueryType query(authKey);
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code(query.getCommandName());
mapper->code(optionValueSerialized, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
list = query.list(options);
::ecorecpp::serializer::serializer _ser;
listSerialized = _ser.serialize_str(list);
//OUT Parameter
diet_string_set(pb,0, "success");
diet_string_set(pb,1, listSerialized);
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, "");
} catch (VishnuException& ex) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
ex.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, ex.what());
}
delete options;
delete list;
return 0;
}
示例6: close
void MappingManager::close(Mapper& mapper) {
if(mapper.hasRules()) {
bool ret = mapper.init() && mapper.close();
mapper.uninit();
if (ret)
log(str(boost::format("Successfully removed port mappings from the %1% device with the %2% interface") % deviceString(mapper) % mapper.getName()), LogManager::LOG_INFO);
else
log(str(boost::format("Failed to remove port mappings from the %1% device with the %2% interface") % deviceString(mapper) % mapper.getName()), LogManager::LOG_WARNING);
}
}
示例7: solveSubmitJob
/**
* \brief Function to solve the jobSubmit service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveSubmitJob(diet_profile_t* pb) {
std::string scriptContent;
std::string machineId;
std::string jsonEncodedOptions;
std::string authKey;
// get profile parameters
diet_string_get(pb,0, authKey);
diet_string_get(pb,1, machineId);
diet_string_get(pb,2, scriptContent);
diet_string_get(pb,3, jsonEncodedOptions);
// reset the profile to send back result
diet_profile_reset(pb, 2);
try {
JsonObject options(jsonEncodedOptions);
std::string scriptPath = options.getStringProperty("scriptpath");
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code("vishnu_submit_job");
mapper->code(scriptPath, mapperkey);
mapper->code(jsonEncodedOptions, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
//FIXME: decode job and options
ServerXMS* server = ServerXMS::getInstance();
JobServer jobServer(authKey, machineId, server->getSedConfig());
jobServer.setDebugLevel(server->getDebugLevel()); // Set the debug level
std::string jobId = jobServer.submitJob(scriptContent,
& options,
server->getDefaultBatchOption());
diet_string_set(pb,0, "success");
diet_string_set(pb,1, JsonObject::serialize(jobServer.getJobInfo(jobId)));
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, jobId);
} catch (VishnuException& ex) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
ex.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, ex.what());
}
return 0;
}
示例8: dump_map
void dump_map(const Mapper&map, const char*file){
FILE* f = fopen(file, "w");
for(int y=0; y<map.height(); ++y){
for(int x=0; x<map.width(); ++x){
fprintf(f, "%5d", map(xyLoc{static_cast<std::int16_t>(x), static_cast<std::int16_t>(y)}));
}
fprintf(f, "\n");
}
fclose(f);
}
示例9: list
/**
* \brief Function to list commands information
* \return The pointer to the UMS_Data::ListCommands containing commands information
* \return raises an exception on error
*/
UMS_Data::ListCommands* list(UMS_Data::ListCmdOptions_ptr option)
{
std::string query;
std::vector<std::string>::iterator ii;
std::vector<std::string> results;
std::string description;
query = "SELECT DISTINCT ctype, vsessionid, name, description, starttime, endtime, command.status"
" FROM vsession, clmachine, command, users"
" WHERE vsession.numsessionid=command.vsession_numsessionid"
" AND vsession.clmachine_numclmachineid=clmachine.numclmachineid"
" AND vsession.users_numuserid=users.numuserid";
UMS_Data::UMS_DataFactory_ptr ecoreFactory = UMS_Data::UMS_DataFactory::_instance();
mlistObject = ecoreFactory->createListCommands();
//Creation of the object user
UserServer userServer = UserServer(msessionServer);
userServer.init();
//if the user exists
if (!userServer.exist()) {
UMSVishnuException e (ERRCODE_UNKNOWN_USER);
throw e;
}
processOptions(userServer, option, query);
query.append(" order by starttime");
//To get the list of commands from the database
boost::scoped_ptr<DatabaseResult> ListOfCommands (mdatabase->getResult(query.c_str()));
for (size_t i = 0; i < ListOfCommands->getNbTuples(); ++i) {
results.clear();
results = ListOfCommands->get(i);
ii = results.begin();
UMS_Data::Command_ptr command = ecoreFactory->createCommand();
vishnu::CmdType currentCmdType = static_cast<vishnu::CmdType>(vishnu::convertToInt(*ii));
command->setCommandId(convertCmdType(static_cast<vishnu::CmdType>(currentCmdType)));
command->setSessionId(*(++ii));
command->setMachineId(*(++ii));
//MAPPER CREATION
Mapper* mapper = MapperRegistry::getInstance()->getMapper(convertypetoMapperName(currentCmdType));
description = mapper->decode(*(++ii));
command->setCmdDescription(description);
command->setCmdStartTime(convertToTimeType(*(++ii)));
command->setCmdEndTime(convertToTimeType(*(++ii)));
command->setStatus(vishnu::convertToInt(*(++ii)));
mlistObject->getCommands().push_back(command);
}
return mlistObject;
}
示例10: solveListOfQueues
/**
* \brief Function to solve the getListOfQueues service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveListOfQueues(diet_profile_t* pb) {
std::string authKey;
std::string machineId;
std::string optionSerialized;
std::string listQueuesSerialized;
diet_string_get(pb,0, authKey);
diet_string_get(pb,1, machineId);
diet_string_get(pb,2, optionSerialized);
// reset profile to handle result
diet_profile_reset(pb, 2);
TMS_Data::ListQueues_ptr listQueues = NULL;
ListQueuesServer queryQueues(authKey,
ServerXMS::getInstance()->getBatchType(),
ServerXMS::getInstance()->getBatchVersion(),
optionSerialized);
try {
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(vishnu::TMSMAPPERNAME);
int mapperkey = mapper->code("vishnu_list_queues");
mapper->code(machineId, mapperkey);
mapper->code(optionSerialized, mapperkey);
std::string cmd = mapper->finalize(mapperkey);
listQueues = queryQueues.list();
::ecorecpp::serializer::serializer _ser;
listQueuesSerialized = _ser.serialize_str(listQueues);
diet_string_set(pb,0, "success");
diet_string_set(pb,1, listQueuesSerialized);
FINISH_COMMAND(authKey, cmd, vishnu::TMS, vishnu::CMDSUCCESS, "");
} catch (VishnuException& ex) {
try {
FINISH_COMMAND(authKey, "", vishnu::TMS, vishnu::CMDFAILED, "");
} catch (VishnuException& fe) {
ex.appendMsgComp(fe.what());
}
diet_string_set(pb,0, "error");
diet_string_set(pb,1, ex.what());
}
return 0;
}
示例11: distributeFiringStimulus
void
distributeFiringStimulus(
const Mapper& mapper,
const std::vector<unsigned>& fstim,
std::vector<SimulationStep>& reqs)
{
for(std::vector<unsigned>::const_iterator i = fstim.begin();
i != fstim.end(); ++i) {
nidx_t neuron = nidx_t(*i);
assert(unsigned(mapper.rankOf(neuron) - 1) < reqs.size());
reqs.at(mapper.rankOf(neuron) - 1).forceFiring(neuron);
}
}
示例12: main
int main(int argc, char *argv[])
{
if(argc == 2) {
string filename(argv[1]);
Mapper mapper;
mapper.Start(false);
mapper.SaveMap(filename);
} else {
cout << "Please supply the filename of the map to save." << endl;
}
}
示例13: main
int main(int argc, char **argv)
{
ros::init(argc, argv, "MapperNode");
ros::NodeHandle n;
// create the mapper
Mapper mapper;
if ((argc > 1) && (strcmp(argv[1], "phase2") == 0)) {
mapper.readMap();
mapper.setToLocalize();
}
// create subscriber for distances
ros::Subscriber dist_sub = n.subscribe("/amee/sensors/irdistances", 100, &Mapper::receive_distances, &mapper);
ros::Subscriber odo_sub = n.subscribe("/amee/motor_control/odometry", 100, &Mapper::receiveOdometry, &mapper);
ros::Subscriber state_sub = n.subscribe("/amee/follow_wall_states",10, &Mapper::receive_FollowWallState, &mapper);
ros::Subscriber tag_sub = n.subscribe("/amee/tag",10, &Mapper::receive_tag, &mapper);
ros::Subscriber command_sub = n.subscribe("/amee/map/mapper_commands",10, &Mapper::receive_MapperCommand, &mapper);
ros::Publisher pose_pub = n.advertise<amee::Pose>("/amee/pose",5);
ros::Publisher marker_pub = n.advertise<amee::MapVisualization>("/amee/map/visualization", 10);
ros::Publisher graph_pub = n.advertise<amee::GraphMsg>("/amee/map/graph",10);
ros::Publisher node_pub = n.advertise<amee::MapperEvent>("/amee/map/mapper_events",10);
mapper.setVisualizationPublisher(marker_pub);
mapper.setGraphPublisher(graph_pub);
mapper.setPosePublisher(pose_pub);
mapper.setNodePublisher(node_pub);
ros::Rate loop_rate(30); //30
// testWallSegment();
while(ros::ok()){
// go to sleep for a short while
loop_rate.sleep();
// call all callbacks
ros::spinOnce();
// // map!
mapper.doMapping();
// mapTest(marker_pub);
}
mapper.saveMap();
return 0;
}
示例14: solveFileTransferStop
/**
* \brief Function to solve the File transfer stop service
* \param pb is a structure which corresponds to the descriptor of a profile
* \return raises an exception on error
*/
int
solveFileTransferStop(diet_profile_t* pb) {
char* sessionKey = NULL;
char* optionsSerialized = NULL;
std::string finishError ="";
int mapperkey;
std::string cmd = "";
std::string errorInfo ="";
diet_string_get(diet_parameter(pb,0), &sessionKey, NULL);
diet_string_get(diet_parameter(pb,1), &optionsSerialized, NULL);
SessionServer sessionServer = SessionServer(std::string(sessionKey));
FMS_Data::StopTransferOptions_ptr options_ptr = NULL;
try {
//MAPPER CREATION
Mapper *mapper = MapperRegistry::getInstance()->getMapper(FMSMAPPERNAME);
mapperkey = mapper->code("vishnu_stop_file_transfer");
mapper->code(std::string(optionsSerialized), mapperkey);
cmd = mapper->finalize(mapperkey);
if(!vishnu::parseEmfObject(std::string(optionsSerialized), options_ptr)) {
SystemException(ERRCODE_INVDATA, "solve_fileTransferStop: options object is not well built");
}
int vishnuId=ServerFMS::getInstance()->getVishnuId();
boost::shared_ptr<FileTransferServer> fileTransferServer(new FileTransferServer(sessionServer,vishnuId));
fileTransferServer->stopThread(*options_ptr);
diet_string_set(diet_parameter(pb,2), strdup(errorInfo.c_str()), DIET_VOLATILE);
sessionServer.finish(cmd, FMS, vishnu::CMDSUCCESS);
} catch (VishnuException& e) {
try {
sessionServer.finish(cmd, FMS, vishnu::CMDFAILED);
} catch (VishnuException& fe) {
finishError = fe.what();
finishError +="\n";
}
e.appendMsgComp(finishError);
errorInfo = e.buildExceptionString();
diet_string_set(diet_parameter(pb,2), strdup(errorInfo.c_str()), DIET_VOLATILE);
}
return 0;
}
示例15: line
void line(int x0,int y0, int x1, int y1, Mapper & mapper ) {
int dx = std::abs(x1-x0);
int dy = std::abs(y1-y0);
int sx,sy,err;
if (x0 < x1 ) {
sx = 1;
} else {
sx = -1;
}
if (y0 < y1) {
sy = 1;
} else {
sy = -1;
}
err = dx-dy;
while(1) {
mapper.map(x0,y0);
if (x0 == x1 && y0 == y1) {
break;
}
int e2 = 2*err;
if (e2 > -dy) {
err = err - dy;
x0 = x0 + sx;
}
if (e2 < dx ) {
err = err + dx;
y0 = y0 + sy;
}
}
}