Ejemplo n.º 1
0
    StreamHandler::StreamHandler(const std::string & appDir_)
        :_appDir(appDir_)
    {
        boost::filesystem::path path(appDir_);
        _oStreamPtr.reset(new std::ofstream(appDir_+"/Merged.txt"));

        FormatAnalyzer analyzer(readFormatString());
        std::regex formatRegex = analyzer.getRegex();
        
        if (boost::filesystem::exists(path) && boost::filesystem::is_directory(path))
        {
            
            boost::filesystem::directory_iterator end_itr;
            for (boost::filesystem::directory_iterator it(path); it != end_itr; it++)
            {
                if (boost::filesystem::is_regular_file(it->status()))
                {
                    if (it->path().filename().string() == ".loginfo")
                    {
                        continue;
                    }

                    _streams.push_back(Tokenizer(
                                           std::shared_ptr<std::ifstream>(
                                               new std::ifstream(appDir_ + "/" + it->path().
                                                                 filename().string())),
                                           formatRegex));
                }
            }
        }
    }
Ejemplo n.º 2
0
void LayoutSVGImage::layout() {
  ASSERT(needsLayout());
  LayoutAnalyzer::Scope analyzer(*this);

  // Invalidate all resources of this client if our layout changed.
  if (everHadLayout() && selfNeedsLayout())
    SVGResourcesCache::clientLayoutChanged(this);

  updateBoundingBox();

  bool updateParentBoundaries = false;
  if (m_needsTransformUpdate) {
    m_localTransform = toSVGImageElement(element())->calculateTransform(
        SVGElement::IncludeMotionTransform);
    m_needsTransformUpdate = false;
    updateParentBoundaries = true;
  }

  if (m_needsBoundariesUpdate) {
    m_localVisualRect = m_objectBoundingBox;
    SVGLayoutSupport::adjustVisualRectWithResources(this, m_localVisualRect);
    m_needsBoundariesUpdate = false;
    updateParentBoundaries = true;
  }

  // If our bounds changed, notify the parents.
  if (updateParentBoundaries)
    LayoutSVGModelObject::setNeedsBoundariesUpdate();

  ASSERT(!m_needsBoundariesUpdate);
  ASSERT(!m_needsTransformUpdate);
  clearNeedsLayout();
}
Ejemplo n.º 3
0
int
_tmain(int argc, const TCHAR *targv[])
{
    // Convert to UTF-8 if necessary
    char **argv;
    drfront_status_t sc = drfront_convert_args(targv, &argv, argc);
    if (sc != DRFRONT_SUCCESS)
        FATAL_ERROR("Failed to process args: %d", sc);

    std::string parse_err;
    if (!droption_parser_t::parse_argv(DROPTION_SCOPE_FRONTEND, argc, (const char **)argv,
                                       &parse_err, NULL) ||
        op_trace.get_value().empty()) {
        FATAL_ERROR("Usage error: %s\nUsage:\n%s", parse_err.c_str(),
                    droption_parser_t::usage_short(DROPTION_SCOPE_ALL).c_str());
    }

    analysis_tool_t *tool = histogram_tool_create(
        op_line_size.get_value(), op_report_top.get_value(), op_verbose.get_value());
    std::vector<analysis_tool_t *> tools;
    tools.push_back(tool);
    analyzer_t analyzer(op_trace.get_value(), &tools[0], (int)tools.size());
    if (!analyzer) {
        FATAL_ERROR("failed to initialize analyzer: %s",
                    analyzer.get_error_string().c_str());
    }
    if (!analyzer.run()) {
        FATAL_ERROR("failed to run analyzer: %s", analyzer.get_error_string().c_str());
    }
    analyzer.print_stats();
    delete tool;

    return 0;
}
Ejemplo n.º 4
0
void ICMainWindow::stop()
{
    stopButton->setEnabled(false);

    ICSystemStore *store = ICSystemStore::getInstance();
    ICQuestion currentQuestion = store->getCurrentQuestion();
    QString id = currentQuestion.getId();
    QList<ICAnswer> answers = store->getAnswers(id);

    ICAnswerAnalyzer analyzer(currentQuestion);
    QMap<QString, int> result = analyzer.analyze(answers);

    ICResultChart *resultChart = new ICResultChart(this);
    resultChart->setTitle(QString(tr("Result of Question %1")).arg(id));
    resultChart->setResult(result);
    resultChart->populate();

    ICResultWindow *resultWindow = new ICResultWindow(resultChart, this);
    resultWindow->resize(800, 600);
    resultWindow->show();

    ICQuestion question;
    store->setCurrentQuestion(question);

    understandButton->setEnabled(true);
    questionButton->setEnabled(true);
}
Ejemplo n.º 5
0
int main(int argc, char* argv[])
{
	if(argc > 1)
	{
		std::string path = argv[1];

		ReadBuffer buffer(path);
		MiniRules rules;
		Scanner scanner(buffer, rules);
		Parser parser(scanner);
		Statement* root = parser.parse();
		if(!parser.errors()) {
			SemanticAnalyzer analyzer(root);
			bool errors = analyzer.analyze();
			if(errors)
			{
				std::cout << std::endl << "There was errors when the semantic analysis, skipping interpretation part." << std::endl;
			} else {
				Interpreter interpreter(root);
				interpreter.interprete();
			}
		} else {
			std::cout << "There was errors during parsing the source, aborting compilation." << std::endl;
		};
	} else {
		std::cout << "No source file given. Please give a source file as the first argument" << std::endl;
	}
	std::cout << std::endl;
	std::cout << "Press a key to continue...";
	std::cin.get();
	return 0;
}
Ejemplo n.º 6
0
void LayoutListMarker::layout() {
  ASSERT(needsLayout());
  LayoutAnalyzer::Scope analyzer(*this);

  if (isImage()) {
    updateMarginsAndContent();
    LayoutSize imageSize(imageBulletSize());
    setWidth(imageSize.width());
    setHeight(imageSize.height());
  } else {
    const SimpleFontData* fontData = style()->font().primaryFont();
    DCHECK(fontData);
    setLogicalWidth(minPreferredLogicalWidth());
    setLogicalHeight(
        LayoutUnit(fontData ? fontData->getFontMetrics().height() : 0));
  }

  setMarginStart(LayoutUnit());
  setMarginEnd(LayoutUnit());

  Length startMargin = style()->marginStart();
  Length endMargin = style()->marginEnd();
  if (startMargin.isFixed())
    setMarginStart(LayoutUnit(startMargin.value()));
  if (endMargin.isFixed())
    setMarginEnd(LayoutUnit(endMargin.value()));

  clearNeedsLayout();
}
Ejemplo n.º 7
0
void LayoutSVGShape::layout()
{
    bool updateCachedBoundariesInParents = false;
    LayoutAnalyzer::Scope analyzer(*this);

    if (m_needsShapeUpdate || m_needsBoundariesUpdate) {
        updateShapeFromElement();
        m_needsShapeUpdate = false;
        updatePaintInvalidationBoundingBox();
        m_needsBoundariesUpdate = false;
        updateCachedBoundariesInParents = true;
    }

    if (m_needsTransformUpdate) {
        updateLocalTransform();
        m_needsTransformUpdate = false;
        updateCachedBoundariesInParents = true;
    }

    // Invalidate all resources of this client if our layout changed.
    if (everHadLayout() && selfNeedsLayout())
        SVGResourcesCache::clientLayoutChanged(this);

    // If our bounds changed, notify the parents.
    if (updateCachedBoundariesInParents)
        LayoutSVGModelObject::setNeedsBoundariesUpdate();

    clearNeedsLayout();
}
void LayoutSVGImage::layout()
{
    ASSERT(needsLayout());
    LayoutAnalyzer::Scope analyzer(*this);

    updateBoundingBox();

    bool transformOrBoundariesUpdate = m_needsTransformUpdate || m_needsBoundariesUpdate;
    if (m_needsTransformUpdate) {
        m_localTransform = toSVGImageElement(element())->calculateAnimatedLocalTransform();
        m_needsTransformUpdate = false;
    }

    if (m_needsBoundariesUpdate) {
        m_paintInvalidationBoundingBox = m_objectBoundingBox;
        SVGLayoutSupport::intersectPaintInvalidationRectWithResources(this, m_paintInvalidationBoundingBox);

        m_needsBoundariesUpdate = false;
    }

    // Invalidate all resources of this client if our layout changed.
    if (everHadLayout() && selfNeedsLayout())
        SVGResourcesCache::clientLayoutChanged(this);

    // If our bounds changed, notify the parents.
    if (transformOrBoundariesUpdate)
        LayoutSVGModelObject::setNeedsBoundariesUpdate();

    clearNeedsLayout();
}
Ejemplo n.º 9
0
//------------------------------------------------------------------------------------------
int main(int argc, char **argv)
{
	if (argc<2) 
		{
		std::cout << "usage:\n    vavagatr filename.asm\n    vavagatr filename.asm -d\n\n";
		exit(1);
		}
	bool debug=false;
	
	
	if (argc==3)
	{
		std::string arg=argv[2];
		if (arg=="-d")
			debug=true;
	}
	
	Registers registers;
	Memory memory(&registers);
	Label label(&memory);
	Analyzer analyzer(&memory,&registers,&label);
	analyzer.loadSyntax("../params/opcodes.cfg");
	analyzer.load(argv[1]);
	analyzer.process();
	if (debug)
		{
		memory.print();
		}
	memory.save("../demo/program.ve");
    return 0;
}
Ejemplo n.º 10
0
void algorithms::KDDecomposer<IROBOT>::AdaptiveDecompose(double larg_radius, double min_radius)
{
    this->ShallowDecompose(larg_radius);
    algorithms::Analyzer<IROBOT> analyzer( *this );
    //importance = analyzer.build_simple_weighted_centrality_matrix(M_PI/8, M_PI/64);
    std::vector<double> importance = analyzer.build_path_importance_matrix(larg_radius * 7, larg_radius);
    // node_index --> importance
    std::unordered_map<int, double> impt_map;
    std::stack<int> stack;
    for( int i = 0; i < this->cells.size(); i++ )
    {
        double cell_radius = get_cell(i).radius();
        if(cell_radius > larg_radius*2)
            continue;
        stack.push(get_cell(i).node_id);
        impt_map[get_cell(i).node_id] = importance[i];
    }
    this->cells.clear();
    
    this->DecomposeSubspaces( stack, larg_radius, min_radius, impt_map );
    this->cells.reserve(nodes.size());
    nodes.shrink_to_fit();
    cells.shrink_to_fit();
    clean_tree();
    build_edges();
}
Ejemplo n.º 11
0
void ChangesNotifier::OnEventsModified(
    gd::Project& game,
    gd::Layout& scene,
    bool indirectChange,
    gd::String sourceOfTheIndirectChange) const {
#if !defined(GD_NO_WX_GUI)  // Compilation is not supported when wxWidgets
                            // support is disabled.
  std::cout << "Changes occured inside " << scene.GetName() << "...";

  scene.SetRefreshNeeded();
  if (!indirectChange ||
      !game.HasExternalEventsNamed(
          sourceOfTheIndirectChange))  // Changes occured directly in the scene:
                                       // Recompile it.
  {
    scene.SetCompilationNeeded();
    CodeCompilationHelpers::CreateSceneEventsCompilationTask(game, scene);
    std::cout << "Recompilation triggered." << std::endl;
  } else {
    DependenciesAnalyzer analyzer(
        game, game.GetExternalEvents(sourceOfTheIndirectChange));
    if (analyzer.ExternalEventsCanBeCompiledForAScene() == scene.GetName()) {
      // Do nothing: Changes occured in an external event which is compiled
      // separately
      std::cout << "But nothing to do." << std::endl;
    } else {
      // Changes occurred in an external event which is directly included in the
      // scene events.
      scene.SetCompilationNeeded();
      std::cout << "Recompilation asked for later." << std::endl;
    }
  }
#endif
}
Ejemplo n.º 12
0
std::string DependenciesAnalyzer::ExternalEventsCanBeCompiledForAScene()
{
    if ( !externalEvents )
    {
        std::cout << "ERROR: ExternalEventsCanBeCompiledForAScene called without external events set!" << std::endl;
        return "";
    }

    std::string sceneName;
    for (unsigned int i = 0;i<project.GetLayoutsCount();++i)
    {
        //For each layout, compute the dependencies and the dependencies which are not coming from a top level event.
        DependenciesAnalyzer analyzer(project, project.GetLayout(i));
        if ( !analyzer.Analyze() ) continue; //Analyze failed -> Cyclic dependencies
        const std::set <std::string > & dependencies = analyzer.GetExternalEventsDependencies();
        const std::set <std::string > & notTopLevelDependencies = analyzer.GetNotTopLevelExternalEventsDependencies();

        //Check if the external events is a dependency, and that is is only present as a link on the top level.
        if ( dependencies.find(externalEvents->GetName()) != dependencies.end() &&
             notTopLevelDependencies.find(externalEvents->GetName()) == notTopLevelDependencies.end() )
        {
            if (!sceneName.empty())
                return ""; //External events can be compiled only if one scene is including them.
            else
                sceneName = project.GetLayout(i).GetName();
        }
    }

    return sceneName; //External events can be compiled and used for the scene.
}
Ejemplo n.º 13
0
bool AndroidExporter::ExportEventsCode(gd::Project& project,
                                       gd::String outputDir) {
  for (std::size_t i = 0; i < project.GetLayoutsCount(); ++i) {
    gd::Layout& exportedLayout = project.GetLayout(i);
    gd::String eventsOutput =
        EventsCodeGenerator::GenerateSceneEventsCompleteCode(
            project, exportedLayout, exportedLayout.GetEvents(), true);

    gd::String filename = "scene" + gd::String::From(i) + ".cpp";

    if (!fs.WriteToFile(outputDir + "/jni/" + filename, eventsOutput))
      return false;
  }

  for (std::size_t i = 0; i < project.GetExternalEventsCount(); ++i) {
    gd::ExternalEvents& externalEvents = project.GetExternalEvents(i);

    DependenciesAnalyzer analyzer(project, externalEvents);
    if (!analyzer.ExternalEventsCanBeCompiledForAScene().empty()) {
      gd::String eventsOutput =
          EventsCodeGenerator::GenerateExternalEventsCompleteCode(
              project, externalEvents, true);

      gd::String filename = "externalEvents" + gd::String::From(i) + ".cpp";

      if (!fs.WriteToFile(outputDir + "/jni/" + filename, eventsOutput))
        return false;
    }
  }

  return true;
}
Ejemplo n.º 14
0
void LayoutListMarker::layout()
{
    ASSERT(needsLayout());
    LayoutAnalyzer::Scope analyzer(*this);

    if (isImage()) {
        updateMarginsAndContent();
        LayoutSize imageSize(imageBulletSize());
        setWidth(imageSize.width());
        setHeight(imageSize.height());
    } else {
        setLogicalWidth(minPreferredLogicalWidth());
        setLogicalHeight(style()->fontMetrics().height());
    }

    setMarginStart(0);
    setMarginEnd(0);

    Length startMargin = style()->marginStart();
    Length endMargin = style()->marginEnd();
    if (startMargin.isFixed())
        setMarginStart(startMargin.value());
    if (endMargin.isFixed())
        setMarginEnd(endMargin.value());

    clearNeedsLayout();
}
Ejemplo n.º 15
0
void peakAnalysis( string filename2 , string filenamelist ) {
   
    TFile * file0 = new TFile(filename2.c_str());
    TFile * file1 = new TFile(filenamelist.c_str());

    TTree * tree = (TTree*)file0->Get("tree");
    TEventList * listsel = (TEventList*)file1->Get("listofselected");

    TCanvas * can = new TCanvas( "canPeaks" , "Peak Analysis" , 7500 , 5500 , 900 , 600 );
    //can->SetLogy();
    can->SetGrid();
    can->cd();

    tree->SetEventList(listsel);
    tree->Draw("GEMDEnergyGauss_1.energy[0]>>htemp(10000,10000,10000)");
    TH1D * spectrum = (TH1D*)gDirectory->Get("htemp");

    spectrum->SetTitle("Energy Spectrum");
    spectrum->SetXTitle("Energy [keV]");
    spectrum->SetYTitle("Counts");
    //spectrum->SetStats(kFALSE);
    
    TSpectrum analyzer( 8 , 2 );
        // arg1: max number of peaks
        // arg2: resolution between peaks
    analyzer.Search( spectrum , 2 , "" , 0.0025);
        // arg2: sigma of the searched peaks
        // arg3: options
        // arg4: peaks with amplitude less than threshold*highest_peak are discarded

    vector<double> peaks;
    for ( int i = 0 ; i < analyzer.GetNPeaks() ; i++ ) {
        peaks.push_back(analyzer.GetPositionX()[i]);
    }
    sort(peaks.begin(),peaks.end());

    cout << endl << "########## PEAKS ##########" << endl;
    for ( int i = 0 ; i < peaks.size() ; i++ ) cout << i+1 << "\t" << peaks.at(i) << endl;

    cout << "###########################" << endl << endl;
   
	if ( peaks.size() < 6 ) { 
		cout << "ERROR: Not enough peaks found, try to modify TSpectrum parameters.\n\n";
		return;
	}

    ofstream file("calib.txt");

    file << "// calibration"                                     << endl
         << "// ch\tkeV"                                         << endl
         << peaks.at(0) << "\t1460.882 // 40K"                   << endl
         << peaks.at(1) << "\t1512.700 // 212Bi"                 << endl
         << peaks.at(2) << "\t1592.515 // 208Tl (double escape)" << endl
         << peaks.at(3) << "\t1620.738 // 212Bi"                 << endl
         << peaks.at(5) << "\t2103.513 // 208Tl (single escape)" << endl
         << peaks.at(6) << "\t2614.511 // 208Tl";

    return;
}
Ejemplo n.º 16
0
void LayoutSVGHiddenContainer::layout()
{
    ASSERT(needsLayout());
    LayoutAnalyzer::Scope analyzer(*this);
    SVGLayoutSupport::layoutChildren(this, selfNeedsLayout());
    updateCachedBoundaries();
    clearNeedsLayout();
}
void test(const vector<string>& args, const unordered_map<string, unordered_map<ControllParam, int>>& except)
{
	CommandParser parser(args);
	parser.GetParamInfoPacket();
	FileAnalysis analyzer(parser.GetParamInfoPacket());
	auto result = analyzer.GetResultPacket().GetResultMap();
	assert(except_eq(*result, except));
}
int main(int argc, char *argv[]) {
  ros::init(argc, argv, "health_analyzer");
  ros::NodeHandle nh;
  ros::NodeHandle pnh("~");
  HealthAnalyzer analyzer(nh, pnh);
  ros::spin();
  return 0;
}
int	main(int argc, char *argv[]) {
	int	numberofstars = 20;
	int	searchradius = 10;
	int	c;
	int	longindex;
	while (EOF != (c = getopt_long(argc, argv, "dh?n:s:", longopts,
		&longindex)))
		switch (c) {
		case 'd':
			debuglevel = LOG_DEBUG;
			break;
		case 'n':
			numberofstars = std::stoi(optarg);
			break;
		case 's':
			searchradius = std::stoi(optarg);
			break;
		case 'h':
		case '?':
			usage(argv[0]);
			return EXIT_SUCCESS;
		default:
			throw std::runtime_error("unknown option");
		}	

	// get the filename from the command line
	if (argc <= optind) {
		std::cerr << "from image file argument missing" << std::endl;
		return EXIT_FAILURE;
	}
	std::string	fromfilename(argv[optind++]);
	if (argc <= optind) {
		std::cerr << "to image file argument missing" << std::endl;
		return EXIT_FAILURE;
	}
	std::string	tofilename(argv[optind++]);

	// read the file
	io::FITSin	fromin(fromfilename);
	ImagePtr	fromimage = fromin.read();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "from image size: %s",
	fromimage->size().toString().c_str());

	io::FITSin	toin(tofilename);
	ImagePtr	toimage = toin.read();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "to image size: %s",
	toimage->size().toString().c_str());

	// find the transform
	TriangleAnalyzer	analyzer(fromimage, numberofstars, searchradius);
	Transform	transform = analyzer.transform(toimage);

	std::cout << "Transform found: " << transform.toString() << std::endl;

	return EXIT_SUCCESS;
}
Ejemplo n.º 20
0
void ChangesNotifier::OnEventsModified(
    gd::Project& game,
    gd::ExternalEvents& events,
    bool indirectChange,
    gd::String sourceOfTheIndirectChange) const {
#if !defined(GD_NO_WX_GUI)  // Compilation is not supported when wxWidgets
                            // support is disabled.
  DependenciesAnalyzer analyzer(game, events);
  gd::String associatedScene = analyzer.ExternalEventsCanBeCompiledForAScene();
  bool externalEventsAreCompiledSeparately = !associatedScene.empty();

  if (!externalEventsAreCompiledSeparately) return;

  std::cout << "Changes occured inside " << events.GetName()
            << " (compiled separately)..." << std::endl;

  // The external events are compiled separately from the scene events:
  // We need to recompile them if the changes occured inside them.

  if (!indirectChange ||
      !game.HasExternalEventsNamed(sourceOfTheIndirectChange)) {
    // Changes occurred directly inside the external events: We need to
    // recompile them
    events.SetLastChangeTimeStamp(wxDateTime::Now().GetTicks());
    CodeCompilationHelpers::CreateExternalEventsCompilationTask(game, events);
    std::cout << "Recompilation triggered." << std::endl;
  } else {
    DependenciesAnalyzer analyzer(
        game, game.GetExternalEvents(sourceOfTheIndirectChange));
    if (analyzer.ExternalEventsCanBeCompiledForAScene() == associatedScene) {
      // Do nothing: Changes occurred in an external event which is compiled
      // separately
      std::cout << "But nothing to do." << std::endl;
    } else {
      // Changes occurred in an another external event which is directly
      // included in our external events.
      events.SetLastChangeTimeStamp(wxDateTime::Now().GetTicks());
      CodeCompilationHelpers::CreateExternalEventsCompilationTask(game, events);
      std::cout << "Recompilation triggered." << std::endl;
    }
  }
#endif
}
Ejemplo n.º 21
0
        AbstractValue analyze(nodename_t node_name, AbstractValue pre) {
          block_t& block = this->get_cfg().get_node(node_name);
          statement_analyzer< AbstractValue > analyzer(pre, _checkpoints);

          for(block_t::iterator it = block.begin(); it != block.end(); ++it) {
            it->accept(&analyzer);
          }

          return analyzer.domain();
        }
Ejemplo n.º 22
0
int main(int argc, char *argv[])
{
  Display disp(std::cout);

  ElementList elements;
  CPPAnalyzer analyzer(elements);

  analyzer.parse(file);
  disp.output(elements);

  return 0;
}
void	AnalyzerTest::testResiduals() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testResiduals() begin");
	// read the chart image
	FITSinfile<float>	chart("testimages/deneb-chart.fits");
	Image<float>	*image1 = chart.read();
	TypeReductionAdapter<double, float>	base(*image1);

	// read the projected image
	FITSinfile<double>	projected("testimages/deneb-projected.fits");
	Image<double>	*image2 = projected.read();

	// compute the residuals
	Analyzer	analyzer(base);
	std::vector<Residual>	residuals = analyzer(*image2);

	debug(LOG_DEBUG, DEBUG_LOG, 0, "%d residuals", residuals.size());
	std::vector<Residual>::const_iterator	r;
	for (r = residuals.begin(); r != residuals.end(); r++) {
		// std::cout << r->first << " -> " << r->second << std::endl;
	}

	debug(LOG_DEBUG, DEBUG_LOG, 0, "testResiduals() end");
}
Ejemplo n.º 24
0
 void run(PassRunner* runner, Module* module) override {
   std::vector<ModuleElement> roots;
   // Module start is a root.
   if (module->start.is()) {
     roots.emplace_back(ModuleElementKind::Function, module->start);
   }
   // Exports are roots.
   for (auto& curr : module->exports) {
     if (curr->kind == ExternalKind::Function) {
       roots.emplace_back(ModuleElementKind::Function, curr->value);
     } else if (curr->kind == ExternalKind::Global) {
       roots.emplace_back(ModuleElementKind::Global, curr->value);
     }
   }
   // For now, all functions that can be called indirectly are marked as roots.
   for (auto& segment : module->table.segments) {
     for (auto& curr : segment.data) {
       roots.emplace_back(ModuleElementKind::Function, curr);
     }
   }
   // Compute reachability starting from the root set.
   ReachabilityAnalyzer analyzer(module, roots);
   // Remove unreachable elements.
   {
     auto& v = module->functions;
     v.erase(std::remove_if(v.begin(), v.end(), [&](const std::unique_ptr<Function>& curr) {
       return analyzer.reachable.count(ModuleElement(ModuleElementKind::Function, curr->name)) == 0;
     }), v.end());
   }
   {
     auto& v = module->globals;
     v.erase(std::remove_if(v.begin(), v.end(), [&](const std::unique_ptr<Global>& curr) {
       return analyzer.reachable.count(ModuleElement(ModuleElementKind::Global, curr->name)) == 0;
     }), v.end());
   }
   {
     auto& v = module->imports;
     v.erase(std::remove_if(v.begin(), v.end(), [&](const std::unique_ptr<Import>& curr) {
       if (curr->kind == ExternalKind::Function) {
         return analyzer.reachable.count(ModuleElement(ModuleElementKind::Function, curr->name)) == 0;
       } else if (curr->kind == ExternalKind::Global) {
         return analyzer.reachable.count(ModuleElement(ModuleElementKind::Global, curr->name)) == 0;
       }
       return false;
     }), v.end());
   }
   module->updateMaps();
 }
Ejemplo n.º 25
0
// load a raw model capture and process it into a matchable set of keypoints, descriptors
void kpoBaseApp::load_model_cloud(string filename, int object_id)
{
    pcl::PointCloud<PointType>::Ptr model_cloud_(new pcl::PointCloud<PointType>());

    pcl::PCDReader reader;
    reader.read<PointType> (filename, *model_cloud_);

    if (model_cloud_->size() != 0) {

        kpoAnalyzerThread analyzer;

        analyzer.downsampling_radius_ = keypoint_downsampling_radius_;
        analyzer.copyInputCloud(*model_cloud_, filename, object_id);
        analyzer.setAnalyzerCallback( boost::bind (&kpoBaseApp::modelCloudAnalyzed, this, _1) );

        analyzer();
    }
}
Ejemplo n.º 26
0
void ChangesNotifier::RequestFullRecompilation(gd::Project& game,
                                               gd::Layout* scene) const {
#if !defined(GD_NO_WX_GUI)  // Compilation is not supported when wxWidgets
                            // support is disabled.
  if (scene) {
    // Notify the scene it has been changed...
    scene->SetRefreshNeeded();

    //...as well as the dependencies
    DependenciesAnalyzer analyzer(game, *scene);
    if (!analyzer.Analyze()) {
      std::cout << "WARNING: Circular dependency for scene " << scene->GetName()
                << std::endl;
      return;
    }

    std::set<gd::String> externalEventsDependencies =
        analyzer.GetExternalEventsDependencies();
    for (std::set<gd::String>::const_iterator i =
             externalEventsDependencies.begin();
         i != externalEventsDependencies.end();
         ++i) {
      if (game.HasExternalEventsNamed(*i))
        game.GetExternalEvents(*i).SetLastChangeTimeStamp(
            wxDateTime::Now().GetTicks());
    }

    // And ask for a recompilation of everything.
    CodeCompilationHelpers::CreateSceneEventsCompilationTask(game, *scene);
  } else  // Scene pointer is NULL: Mark all scenes as modified
  {
    for (std::size_t i = 0; i < game.GetLayoutsCount(); ++i) {
      game.GetLayout(i).SetRefreshNeeded();
      game.GetLayout(i).SetCompilationNeeded();
    }
    for (std::size_t i = 0; i < game.GetExternalEventsCount(); ++i) {
      game.GetExternalEvents(i).SetLastChangeTimeStamp(
          wxDateTime::Now()
              .GetTicks());  // Do no forget external events as they can have
                             // been compiled separately from scenes.
    }
  }
#endif
}
int main( int argc, char** argv ) {

	hydrazine::ArgumentParser parser( argc, argv );
	
	parser.description("Provides the ability to inspect a database created by" 
		+ std::string( "a InstructionTraceGenerator - output is in Python object notation on stdout" ) );
	
	bool help;
	bool list;
	bool instructions_by_kernel = false;
	bool instructions_by_app = false;
	bool pyList = false;
	std::string database;

	parser.parse( "-h", help, false, "Print this help message." );
	parser.parse( "-i", database, "traces/database.trace", "Path to database file." );
	parser.parse( "-a", instructions_by_app, false,
		"Compute instruction histogram for each application over all its kernels");
	parser.parse( "-k", instructions_by_kernel, false,
		"Compute instruction histogram for each kernel" );
	parser.parse( "-l", list, false, "List all traces in the database." );
	parser.parse( "-r", pyList, false, "Print results as a Python list rather than Pyson");
		
	if( help ) {
		std::cout << parser.help();
		return 0;
	}
	
	trace::InstructionTraceAnalyzer analyzer( database );
	
	if( list ) {
		analyzer.list();	
	}
	
	if( instructions_by_kernel ) {
		analyzer.instructions_by_kernel(pyList);
	}

	if( instructions_by_app ) {
		analyzer.instructions_by_application(pyList);
	}
	
	return 0;
}
Ejemplo n.º 28
0
bool filterBlockWithQuery(ASTPtr query, Block & block, const Context & context)
{
	query = query->clone();
	const ASTSelectQuery & select = typeid_cast<ASTSelectQuery & >(*query);
	if (!select.where_expression && !select.prewhere_expression)
		return false;

	NameSet columns;
	for (const auto & it : block.getColumnsList())
		columns.insert(it.name);

	/// Составим выражение, вычисляющее выражения в WHERE и PREWHERE, зависящие только от имеющихся столбцов.
	std::vector<ASTPtr> functions;
	if (select.where_expression)
		extractFunctions(select.where_expression, columns, functions);
	if (select.prewhere_expression)
		extractFunctions(select.prewhere_expression, columns, functions);
	ASTPtr expression_ast = buildWhereExpression(functions);
	if (!expression_ast)
		return false;

	/// Распарсим и вычислим выражение.
	ExpressionAnalyzer analyzer(expression_ast, context, {}, block.getColumnsList());
	ExpressionActionsPtr actions = analyzer.getActions(false);
	actions->execute(block);

	/// Отфильтруем блок.
	String filter_column_name = expression_ast->getColumnName();
	ColumnPtr filter_column = block.getByName(filter_column_name).column;
	if (auto converted = filter_column->convertToFullColumnIfConst())
		filter_column = converted;
	const IColumn::Filter & filter = dynamic_cast<ColumnUInt8 &>(*filter_column).getData();

	if (std::accumulate(filter.begin(), filter.end(), 0ul) == filter.size())
		return false;

	for (size_t i = 0; i < block.columns(); ++i)
	{
		ColumnPtr & column = block.safeGetByPosition(i).column;
		column = column->filter(filter, -1);
	}

	return true;
}
Ejemplo n.º 29
0
bool filterBlockWithQuery(const ASTPtr & query, Block & block, const Context & context)
{
    const ASTSelectQuery & select = typeid_cast<const ASTSelectQuery & >(*query);
    if (!select.where_expression && !select.prewhere_expression)
        return false;

    NameSet columns;
    for (const auto & it : block.getColumnsList())
        columns.insert(it.name);

    /// We will create an expression that evaluates the expressions in WHERE and PREWHERE, depending only on the existing columns.
    std::vector<ASTPtr> functions;
    if (select.where_expression)
        extractFunctions(select.where_expression, columns, functions);
    if (select.prewhere_expression)
        extractFunctions(select.prewhere_expression, columns, functions);
    ASTPtr expression_ast = buildWhereExpression(functions);
    if (!expression_ast)
        return false;

    /// Let's parse and calculate the expression.
    ExpressionAnalyzer analyzer(expression_ast, context, {}, block.getColumnsList());
    ExpressionActionsPtr actions = analyzer.getActions(false);
    actions->execute(block);

    /// Filter the block.
    String filter_column_name = expression_ast->getColumnName();
    ColumnPtr filter_column = block.getByName(filter_column_name).column;
    if (auto converted = filter_column->convertToFullColumnIfConst())
        filter_column = converted;
    const IColumn::Filter & filter = dynamic_cast<ColumnUInt8 &>(*filter_column).getData();

    if (countBytesInFilter(filter) == 0)
        return false;

    for (size_t i = 0; i < block.columns(); ++i)
    {
        ColumnPtr & column = block.safeGetByPosition(i).column;
        column = column->filter(filter, -1);
    }

    return true;
}
Ejemplo n.º 30
0
int main (int argc, char ** argv) 
{
  /*
  char inputFileName[150];
  if ( argc < 2 ){
    std::cout << "missing argument: insert inputFile with list of root files" << std::endl; 
    return 1;
  }

  TChain *theChain = new TChain("OniaTree");

  TList *treelist = new TList();

  for(int i=1;i<argc;i++){

    string filename(argv[i]);
    filename += "/makeNtple";

    cout << "Adding " << filename.c_str() << endl;

    theChain->Add(filename.c_str());
  }

  cout << "Total number of entries" << theChain->GetEntries() << endl;
  */
  
  TChain * albero = new TChain ("makeNtple/OniaTree") ;
  string filename(argv[1]);
  filename += "*.root" ;
  albero -> Add(filename.c_str());
  std::cout << "al : " << albero->GetEntries () << std::endl ;

  string outputfile(argv[2]);
  outputfile += ".root" ;
  TFile *f1 = new TFile(outputfile.c_str(),"RECREATE");  

  MuMuLooper analyzer(albero);
  analyzer.Loop(filename);
  analyzer.saveHistos(f1);
  delete albero;

  return 0;
}