Fixed after changes to the Moses code structure.

--- moses-cmd/simulate-pe.cc
+++ moses-cmd/simulate-pe.cc
@@ -1,5 +1,4 @@
-// Fork of Main.cpp, to simulate post-editing sessions.
-// Written by Ulrich Germann.
+// $Id: MainMT.cpp 3045 2010-04-05 13:07:29Z hieuhoang1972 $

 /***********************************************************************
 Moses - factored phrase-based language decoder
@@ -20,44 +19,41 @@
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 ***********************************************************************/

-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/iostreams/device/file.hpp>
-#include <boost/iostreams/filter/bzip2.hpp>
-#include <boost/iostreams/filter/gzip.hpp>
-#include <boost/iostreams/filtering_stream.hpp>
-#include <boost/foreach.hpp>
-
+/**
+ * Moses main, for single-threaded and multi-threaded.
+ **/
 #include <exception>
 #include <fstream>
 #include <sstream>
 #include <vector>

+#include <boost/program_options.hpp>
 #include "util/usage.hh"
 #include "util/exception.hh"
 #include "moses/Util.h"
+
+#ifdef PT_UG
 #include "moses/TranslationModel/UG/mmsapt.h"
 #include "moses/TranslationModel/UG/generic/program_options/ug_splice_arglist.h"
+#endif

 #ifdef WIN32
 // Include Visual Leak Detector
 //#include <vld.h>
 #endif

-#include "moses/TranslationAnalysis.h"
-#include "IOWrapper.h"
-#include "mbr.h"
-
+#include "moses/IOWrapper.h"
 #include "moses/Hypothesis.h"
+#include "moses/HypergraphOutput.h"
 #include "moses/Manager.h"
 #include "moses/StaticData.h"
+#include "moses/TypeDef.h"
 #include "moses/Util.h"
 #include "moses/Timer.h"
-#include "moses/ThreadPool.h"
-#include "moses/OutputCollector.h"
 #include "moses/TranslationModel/PhraseDictionary.h"
 #include "moses/FF/StatefulFeatureFunction.h"
 #include "moses/FF/StatelessFeatureFunction.h"
+#include "moses/TranslationTask.h"

 #ifdef HAVE_PROTOBUF
 #include "hypergraph.pb.h"
@@ -65,522 +61,15 @@

 using namespace std;
 using namespace Moses;
-using namespace MosesCmd;
-
-namespace MosesCmd
+
+namespace Moses
 {
-// output floats with five significant digits
-static const size_t PRECISION = 3;
-
-/** Enforce rounding */
-void fix(std::ostream& stream, size_t size)
-{
-  stream.setf(std::ios::fixed);
-  stream.precision(size);
-}
-
-/** Translates a sentence.
-  * - calls the search (Manager)
-  * - applies the decision rule
-  * - outputs best translation and additional reporting
-  **/
-class TranslationTask : public Task
-{
-
-public:
-
-  TranslationTask(size_t lineNumber,
-                  InputType* source,
-		  OutputCollector* outputCollector,
-		  OutputCollector* nbestCollector,
-                  OutputCollector* latticeSamplesCollector,
-                  OutputCollector* wordGraphCollector,
-		  OutputCollector* searchGraphCollector,
-                  OutputCollector* detailedTranslationCollector,
-                  OutputCollector* alignmentInfoCollector,
-                  OutputCollector* unknownsCollector,
-                  bool outputSearchGraphSLF,
-                  bool outputSearchGraphHypergraph)
-    : m_source(source)
-    , m_lineNumber(lineNumber)
-    , m_outputCollector(outputCollector)
-    , m_nbestCollector(nbestCollector)
-    , m_latticeSamplesCollector(latticeSamplesCollector)
-    , m_wordGraphCollector(wordGraphCollector)
-    , m_searchGraphCollector(searchGraphCollector)
-    , m_detailedTranslationCollector(detailedTranslationCollector)
-    , m_alignmentInfoCollector(alignmentInfoCollector)
-    , m_unknownsCollector(unknownsCollector)
-    , m_outputSearchGraphSLF(outputSearchGraphSLF)
-    , m_outputSearchGraphHypergraph(outputSearchGraphHypergraph)
-  { }
-
-  /** Translate one sentence
-   * gets called by main function implemented at end of this source file */
-  void Run() {
-    // shorthand for "global data"
-    const StaticData &staticData = StaticData::Instance();
-
-    // input sentence
-    Sentence sentence;
-
-    // report wall time spent on translation
-    Timer translationTime;
-    translationTime.start();
-
-    // report thread number
-#if defined(WITH_THREADS) && defined(BOOST_HAS_PTHREADS)
-    TRACE_ERR("Translating line " << m_lineNumber << "  in thread id " << pthread_self() << std::endl);
-#endif
-
-
-    // execute the translation
-    // note: this executes the search, resulting in a search graph
-    //       we still need to apply the decision rule (MAP, MBR, ...)
-    Timer initTime;
-    initTime.start();
-    Manager manager(m_lineNumber, *m_source,staticData.GetSearchAlgorithm());
-    VERBOSE(1, "Line " << m_lineNumber << ": Initialize search took " << initTime << " seconds total" << endl);
-    manager.ProcessSentence();
-
-    // we are done with search, let's look what we got
-    Timer additionalReportingTime;
-    additionalReportingTime.start();
-
-    // output word graph
-    if (m_wordGraphCollector) {
-      ostringstream out;
-      fix(out,PRECISION);
-      manager.GetWordGraph(m_lineNumber, out);
-      m_wordGraphCollector->Write(m_lineNumber, out.str());
-    }
-
-    // output search graph
-    if (m_searchGraphCollector) {
-      ostringstream out;
-      fix(out,PRECISION);
-      manager.OutputSearchGraph(m_lineNumber, out);
-      m_searchGraphCollector->Write(m_lineNumber, out.str());
-
-#ifdef HAVE_PROTOBUF
-      if (staticData.GetOutputSearchGraphPB()) {
-        ostringstream sfn;
-        sfn << staticData.GetParam("output-search-graph-pb")[0] << '/' << m_lineNumber << ".pb" << ends;
-        string fn = sfn.str();
-        VERBOSE(2, "Writing search graph to " << fn << endl);
-        fstream output(fn.c_str(), ios::trunc | ios::binary | ios::out);
-        manager.SerializeSearchGraphPB(m_lineNumber, output);
-      }
-#endif
-    }
-
-    // Output search graph in HTK standard lattice format (SLF)
-    if (m_outputSearchGraphSLF) {
-      stringstream fileName;
-      fileName << staticData.GetParam("output-search-graph-slf")[0] << "/" << m_lineNumber << ".slf";
-      std::ofstream *file = new std::ofstream;
-      file->open(fileName.str().c_str());
-      if (file->is_open() && file->good()) {
-        ostringstream out;
-        fix(out,PRECISION);
-        manager.OutputSearchGraphAsSLF(m_lineNumber, out);
-        *file << out.str();
-        file -> flush();
-      } else {
-        TRACE_ERR("Cannot output HTK standard lattice for line " << m_lineNumber << " because the output file is not open or not ready for writing" << std::endl);
-      }
-      delete file;
-    }
-
-    // Output search graph in hypergraph format for Kenneth Heafield's lazy hypergraph decoder
-    if (m_outputSearchGraphHypergraph) {
-
-      vector<string> hypergraphParameters = staticData.GetParam("output-search-graph-hypergraph");
-
-      bool appendSuffix;
-      if (hypergraphParameters.size() > 0 && hypergraphParameters[0] == "true") {
-        appendSuffix = true;
-      } else {
-        appendSuffix = false;
-      }
-
-      string compression;
-      if (hypergraphParameters.size() > 1) {
-        compression = hypergraphParameters[1];
-      } else {
-        compression = "txt";
-      }
-
-      string hypergraphDir;
-      if ( hypergraphParameters.size() > 2 ) {
-        hypergraphDir = hypergraphParameters[2];
-      } else {
-        string nbestFile = staticData.GetNBestFilePath();
-        if ( ! nbestFile.empty() && nbestFile!="-" && !boost::starts_with(nbestFile,"/dev/stdout") ) {
-          boost::filesystem::path nbestPath(nbestFile);
-
-          // In the Boost filesystem API version 2,
-          //   which was the default prior to Boost 1.46,
-          //   the filename() method returned a string.
-          //
-          // In the Boost filesystem API version 3,
-          //   which is the default starting with Boost 1.46,
-          //   the filename() method returns a path object.
-          //
-          // To get a string from the path object,
-          //   the native() method must be called.
-          //	  hypergraphDir = nbestPath.parent_path().filename()
-          //#if BOOST_VERSION >= 104600
-          //	    .native()
-          //#endif
-          //;
-
-          // Hopefully the following compiles under all versions of Boost.
-          //
-          // If this line gives you compile errors,
-          //   contact Lane Schwartz on the Moses mailing list
-          hypergraphDir = nbestPath.parent_path().string();
-
-        } else {
-          stringstream hypergraphDirName;
-          hypergraphDirName << boost::filesystem::current_path().string() << "/hypergraph";
-          hypergraphDir = hypergraphDirName.str();
-        }
-      }
-
-      if ( ! boost::filesystem::exists(hypergraphDir) ) {
-        boost::filesystem::create_directory(hypergraphDir);
-      }
-
-      if ( ! boost::filesystem::exists(hypergraphDir) ) {
-        TRACE_ERR("Cannot output hypergraphs to " << hypergraphDir << " because the directory does not exist" << std::endl);
-      } else if ( ! boost::filesystem::is_directory(hypergraphDir) ) {
-        TRACE_ERR("Cannot output hypergraphs to " << hypergraphDir << " because that path exists, but is not a directory" << std::endl);
-      } else {
-        stringstream fileName;
-        fileName << hypergraphDir << "/" << m_lineNumber;
-        if ( appendSuffix ) {
-          fileName << "." << compression;
-        }
-        boost::iostreams::filtering_ostream *file
-	  = new boost::iostreams::filtering_ostream;
-
-        if ( compression == "gz" ) {
-          file->push( boost::iostreams::gzip_compressor() );
-        } else if ( compression == "bz2" ) {
-          file->push( boost::iostreams::bzip2_compressor() );
-        } else if ( compression != "txt" ) {
-          TRACE_ERR("Unrecognized hypergraph compression format ("
-		    << compression
-		    << ") - using uncompressed plain txt" << std::endl);
-          compression = "txt";
-        }
-
-        file->push( boost::iostreams::file_sink(fileName.str(), ios_base::out) );
-
-        if (file->is_complete() && file->good()) {
-          fix(*file,PRECISION);
-          manager.OutputSearchGraphAsHypergraph(*file);
-          file -> flush();
-        } else {
-          TRACE_ERR("Cannot output hypergraph for line " << m_lineNumber
-		    << " because the output file " << fileName.str()
-		    << " is not open or not ready for writing"
-		    << std::endl);
-        }
-        file -> pop();
-        delete file;
-      }
-    }
-    additionalReportingTime.stop();
-
-    // apply decision rule and output best translation(s)
-    if (m_outputCollector) {
-      ostringstream out;
-      ostringstream debug;
-      fix(debug,PRECISION);
-
-      // all derivations - send them to debug stream
-      if (staticData.PrintAllDerivations()) {
-        additionalReportingTime.start();
-        manager.PrintAllDerivations(m_lineNumber, debug);
-        additionalReportingTime.stop();
-      }
-
-      Timer decisionRuleTime;
-      decisionRuleTime.start();
-
-      // MAP decoding: best hypothesis
-      const Hypothesis* bestHypo = NULL;
-      if (!staticData.UseMBR()) {
-        bestHypo = manager.GetBestHypothesis();
-        if (bestHypo) {
-          if (StaticData::Instance().GetOutputHypoScore()) {
-            out << bestHypo->GetTotalScore() << ' ';
-          }
-          if (staticData.IsPathRecoveryEnabled()) {
-            OutputInput(out, bestHypo);
-            out << "||| ";
-          }
-          if (staticData.GetParam("print-id").size() && Scan<bool>(staticData.GetParam("print-id")[0]) ) {
-            out << m_source->GetTranslationId() << " ";
-          }
-
-	  if (staticData.GetReportSegmentation() == 2) {
-	    manager.GetOutputLanguageModelOrder(out, bestHypo);
-	  }
-          OutputBestSurface(
-            out,
-            bestHypo,
-            staticData.GetOutputFactorOrder(),
-            staticData.GetReportSegmentation(),
-            staticData.GetReportAllFactors());
-          if (staticData.PrintAlignmentInfo()) {
-            out << "||| ";
-            OutputAlignment(out, bestHypo);
-          }
-
-          OutputAlignment(m_alignmentInfoCollector, m_lineNumber, bestHypo);
-          IFVERBOSE(1) {
-            debug << "BEST TRANSLATION: " << *bestHypo << endl;
-          }
-        } else {
-          VERBOSE(1, "NO BEST TRANSLATION" << endl);
-        }
-
-        out << endl;
-      }
-
-      // MBR decoding (n-best MBR, lattice MBR, consensus)
-      else {
-        // we first need the n-best translations
-        size_t nBestSize = staticData.GetMBRSize();
-        if (nBestSize <= 0) {
-          cerr << "ERROR: negative size for number of MBR candidate translations not allowed (option mbr-size)" << endl;
-          exit(1);
-        }
-        TrellisPathList nBestList;
-        manager.CalcNBest(nBestSize, nBestList,true);
-        VERBOSE(2,"size of n-best: " << nBestList.GetSize() << " (" << nBestSize << ")" << endl);
-        IFVERBOSE(2) {
-          PrintUserTime("calculated n-best list for (L)MBR decoding");
-        }
-
-        // lattice MBR
-        if (staticData.UseLatticeMBR()) {
-          if (m_nbestCollector) {
-            //lattice mbr nbest
-            vector<LatticeMBRSolution> solutions;
-            size_t n  = min(nBestSize, staticData.GetNBestSize());
-            getLatticeMBRNBest(manager,nBestList,solutions,n);
-            ostringstream out;
-            OutputLatticeMBRNBest(out, solutions,m_lineNumber);
-            m_nbestCollector->Write(m_lineNumber, out.str());
-          } else {
-            //Lattice MBR decoding
-            vector<Word> mbrBestHypo = doLatticeMBR(manager,nBestList);
-            OutputBestHypo(mbrBestHypo, m_lineNumber, staticData.GetReportSegmentation(),
-                           staticData.GetReportAllFactors(),out);
-            IFVERBOSE(2) {
-              PrintUserTime("finished Lattice MBR decoding");
-            }
-          }
-        }
-
-        // consensus decoding
-        else if (staticData.UseConsensusDecoding()) {
-          const TrellisPath &conBestHypo = doConsensusDecoding(manager,nBestList);
-          OutputBestHypo(conBestHypo, m_lineNumber,
-                         staticData.GetReportSegmentation(),
-                         staticData.GetReportAllFactors(),out);
-          OutputAlignment(m_alignmentInfoCollector, m_lineNumber, conBestHypo);
-          IFVERBOSE(2) {
-            PrintUserTime("finished Consensus decoding");
-          }
-        }
-
-        // n-best MBR decoding
-        else {
-          const Moses::TrellisPath &mbrBestHypo = doMBR(nBestList);
-          OutputBestHypo(mbrBestHypo, m_lineNumber,
-                         staticData.GetReportSegmentation(),
-                         staticData.GetReportAllFactors(),out);
-          OutputAlignment(m_alignmentInfoCollector, m_lineNumber, mbrBestHypo);
-          IFVERBOSE(2) {
-            PrintUserTime("finished MBR decoding");
-          }
-        }
-      }
-
-      // report best translation to output collector
-      m_outputCollector->Write(m_lineNumber,out.str(),debug.str());
-
-      decisionRuleTime.stop();
-      VERBOSE(1, "Line " << m_lineNumber << ": Decision rule took " << decisionRuleTime << " seconds total" << endl);
-    }
-
-    additionalReportingTime.start();
-
-    // output n-best list
-    if (m_nbestCollector && !staticData.UseLatticeMBR()) {
-      TrellisPathList nBestList;
-      ostringstream out;
-      manager.CalcNBest(staticData.GetNBestSize(), nBestList,staticData.GetDistinctNBest());
-      OutputNBest(out, nBestList, staticData.GetOutputFactorOrder(), m_lineNumber,
-                  staticData.GetReportSegmentation());
-      m_nbestCollector->Write(m_lineNumber, out.str());
-    }
-
-    //lattice samples
-    if (m_latticeSamplesCollector) {
-      TrellisPathList latticeSamples;
-      ostringstream out;
-      manager.CalcLatticeSamples(staticData.GetLatticeSamplesSize(), latticeSamples);
-      OutputNBest(out,latticeSamples, staticData.GetOutputFactorOrder(), m_lineNumber,
-                  staticData.GetReportSegmentation());
-      m_latticeSamplesCollector->Write(m_lineNumber, out.str());
-    }
-
-    // detailed translation reporting
-    if (m_detailedTranslationCollector) {
-      ostringstream out;
-      fix(out,PRECISION);
-      TranslationAnalysis::PrintTranslationAnalysis(out, manager.GetBestHypothesis());
-      m_detailedTranslationCollector->Write(m_lineNumber,out.str());
-    }
-
-    //list of unknown words
-    if (m_unknownsCollector) {
-      const vector<const Phrase*>& unknowns = manager.getSntTranslationOptions()->GetUnknownSources();
-      ostringstream out;
-      for (size_t i = 0; i < unknowns.size(); ++i) {
-        out << *(unknowns[i]);
-      }
-      out << endl;
-      m_unknownsCollector->Write(m_lineNumber, out.str());
-    }
-
-    // report additional statistics
-    manager.CalcDecoderStatistics();
-    VERBOSE(1, "Line " << m_lineNumber << ": Additional reporting took " << additionalReportingTime << " seconds total" << endl);
-    VERBOSE(1, "Line " << m_lineNumber << ": Translation took " << translationTime << " seconds total" << endl);
-    IFVERBOSE(2) {
-      PrintUserTime("Sentence Decoding Time:");
-    }
-  }
-
-  ~TranslationTask() {
-    delete m_source;
-  }
-
-private:
-  InputType* m_source;
-  size_t m_lineNumber;
-  OutputCollector* m_outputCollector;
-  OutputCollector* m_nbestCollector;
-  OutputCollector* m_latticeSamplesCollector;
-  OutputCollector* m_wordGraphCollector;
-  OutputCollector* m_searchGraphCollector;
-  OutputCollector* m_detailedTranslationCollector;
-  OutputCollector* m_alignmentInfoCollector;
-  OutputCollector* m_unknownsCollector;
-  bool m_outputSearchGraphSLF;
-  bool m_outputSearchGraphHypergraph;
-  std::ofstream *m_alignmentStream;
-
-
-};
-
-static void PrintFeatureWeight(const FeatureFunction* ff)
-{
-  cout << ff->GetScoreProducerDescription() << "=";
-  size_t numScoreComps = ff->GetNumScoreComponents();
-  vector<float> values = StaticData::Instance().GetAllWeights().GetScoresForProducer(ff);
-  for (size_t i = 0; i < numScoreComps; ++i) {
-    cout << " " << values[i];
-  }
-  cout << endl;
-}
-
-static void ShowWeights()
-{
-  //TODO: Find a way of ensuring this order is synced with the nbest
-  fix(cout,6);
-  const vector<const StatelessFeatureFunction*>& slf = StatelessFeatureFunction::GetStatelessFeatureFunctions();
-  const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
-
-  for (size_t i = 0; i < sff.size(); ++i) {
-    const StatefulFeatureFunction *ff = sff[i];
-    if (ff->IsTuneable()) {
-      PrintFeatureWeight(ff);
-    }
-    else {
-      cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
-    }
-  }
-  for (size_t i = 0; i < slf.size(); ++i) {
-    const StatelessFeatureFunction *ff = slf[i];
-    if (ff->IsTuneable()) {
-      PrintFeatureWeight(ff);
-    }
-    else {
-      cout << ff->GetScoreProducerDescription() << " UNTUNEABLE" << endl;
-    }
-  }
-}
-
-size_t OutputFeatureWeightsForHypergraph(size_t index, const FeatureFunction* ff, std::ostream &outputSearchGraphStream)
-{
-  size_t numScoreComps = ff->GetNumScoreComponents();
-  if (numScoreComps != 0) {
-    vector<float> values = StaticData::Instance().GetAllWeights().GetScoresForProducer(ff);
-    if (numScoreComps > 1) {
-      for (size_t i = 0; i < numScoreComps; ++i) {
-        outputSearchGraphStream << ff->GetScoreProducerDescription()
-                                << i
-                                << "=" << values[i] << endl;
-      }
-    } else {
-      outputSearchGraphStream << ff->GetScoreProducerDescription()
-                              << "=" << values[0] << endl;
-    }
-    return index+numScoreComps;
-  } else {
-    UTIL_THROW2("Sparse features are not yet supported when outputting hypergraph format");
-  }
-}

 void OutputFeatureWeightsForHypergraph(std::ostream &outputSearchGraphStream)
 {
   outputSearchGraphStream.setf(std::ios::fixed);
   outputSearchGraphStream.precision(6);
-
-  const vector<const StatelessFeatureFunction*>& slf =StatelessFeatureFunction::GetStatelessFeatureFunctions();
-  const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
-  size_t featureIndex = 1;
-  for (size_t i = 0; i < sff.size(); ++i) {
-    featureIndex = OutputFeatureWeightsForHypergraph(featureIndex, sff[i], outputSearchGraphStream);
-  }
-  for (size_t i = 0; i < slf.size(); ++i) {
-    /*
-    if (slf[i]->GetScoreProducerWeightShortName() != "u" &&
-          slf[i]->GetScoreProducerWeightShortName() != "tm" &&
-          slf[i]->GetScoreProducerWeightShortName() != "I" &&
-          slf[i]->GetScoreProducerWeightShortName() != "g")
-    */
-    {
-      featureIndex = OutputFeatureWeightsForHypergraph(featureIndex, slf[i], outputSearchGraphStream);
-    }
-  }
-  const vector<PhraseDictionary*>& pds = PhraseDictionary::GetColl();
-  for( size_t i=0; i<pds.size(); i++ ) {
-    featureIndex = OutputFeatureWeightsForHypergraph(featureIndex, pds[i], outputSearchGraphStream);
-  }
-  const vector<GenerationDictionary*>& gds = GenerationDictionary::GetColl();
-  for( size_t i=0; i<gds.size(); i++ ) {
-    featureIndex = OutputFeatureWeightsForHypergraph(featureIndex, gds[i], outputSearchGraphStream);
-  }
-
+  StaticData::Instance().GetAllWeights().Save(outputSearchGraphStream);
 }

@@ -603,9 +92,36 @@
     }

     // set number of significant decimals in output
-    fix(cout,PRECISION);
-    fix(cerr,PRECISION);
-
+    // By the way, having a static member function in an Moses-specific class
+    // just to do
+    // cout.setf(ios::fixed);cout.precision(3);
+    // doesn't make sense.
+    // 1. It makes the program harder to understand. If I see
+    //    cout.setf(ios::fixed);cout.precision(3);
+    //    I know immediately what's going on. If I see,
+    //    IOWrapper::FixPrecision(cout);
+    //    I assume that something much more elaborate is going on (side effects?)
+    //    and need to look it up.
+    //    After all, one reads programs in order to understand them.
+    // 2. If you want to enforce a certain default behaviour on stdout,
+    //    that should happen only once. Other components should not do that.
+    // 3. If you want to format locally, use
+    //    string IOWrapper::score_default_formatting = "%.3f";
+    //    cout << boost::format(IOWrapper::score_default_formatting) % my_variable;
+    //    This even allows you to do pretty printing by default if you wish.
+    //    (Actually, the format variable should be constructed
+    //    from an int IOWrapper::score_output_default_precision itself.)
+    // 4. If output speed is an issue and you are afraid of the overhead that
+    //    boost::format may add, don't use streams to begin with.
+    // IOWrapper::FixPrecision(cout);
+    // IOWrapper::FixPrecision(cerr);
+    cout.setf(ios::fixed); cout.precision(3);
+    cout.setf(ios::fixed); cout.precision(3);
+
+#ifdef PT_UG
+    // see my notes on the moses support mailing list, this is a hack around
+    // the misguided implementation of LoadParameter(), which should leave
+    // arguments it doesn't know alone.
     vector<pair<string,int> > argfilter(4);
     argfilter[0] = std::make_pair(string("--spe-src"),1);
     argfilter[1] = std::make_pair(string("--spe-trg"),1);
@@ -616,16 +132,16 @@
     filter_arguments(argc, argv, mo_acnt, &mo_args, my_acnt, &my_args, argfilter);

     ifstream spe_src,spe_trg,spe_aln;
-    // instead of translating show coverage by phrase tables
     for (int i = 0; i < my_acnt; i += 2)
       {
-	if (!strcmp(my_args[i],"--spe-src"))
-	  spe_src.open(my_args[i+1]);
-	else if (!strcmp(my_args[i],"--spe-trg"))
-	  spe_trg.open(my_args[i+1]);
-	else if (!strcmp(my_args[i],"--spe-aln"))
-	  spe_aln.open(my_args[i+1]);
-      }
+        if (!strcmp(my_args[i],"--spe-src"))
+          spe_src.open(my_args[i+1]);
+        else if (!strcmp(my_args[i],"--spe-trg"))
+          spe_trg.open(my_args[i+1]);
+        else if (!strcmp(my_args[i],"--spe-aln"))
+          spe_aln.open(my_args[i+1]);
+      }
+#endif

     // load all the settings into the Parameter class
     // (stores them as strings, or array of strings)
@@ -634,7 +150,6 @@
       exit(1);
     }

-
     // initialize all "global" variables, which are stored in StaticData
     // note: this also loads models such as the language model, etc.
     if (!StaticData::LoadDataStatic(&params, argv[0])) {
@@ -650,12 +165,11 @@
     // shorthand for accessing information in StaticData
     const StaticData& staticData = StaticData::Instance();

-
     //initialise random numbers
     srand(time(NULL));

     // set up read/writing class
-    IOWrapper* ioWrapper = GetIOWrapper(staticData);
+    IOWrapper* ioWrapper = IOWrapper::GetIOWrapper(staticData);
     if (!ioWrapper) {
       cerr << "Error; Failed to create IO object" << endl;
       exit(1);
@@ -668,113 +182,17 @@
       TRACE_ERR(weights);
       TRACE_ERR("\n");
     }
+
+    boost::shared_ptr<HypergraphOutput<Manager> > hypergraphOutput;
+    boost::shared_ptr<HypergraphOutput<ChartManager> > hypergraphOutputChart;
+
     if (staticData.GetOutputSearchGraphHypergraph()) {
-      ofstream* weightsOut = new std::ofstream;
-      stringstream weightsFilename;
-      if (staticData.GetParam("output-search-graph-hypergraph").size() > 3) {
-        weightsFilename << staticData.GetParam("output-search-graph-hypergraph")[3];
-      } else {
-        string nbestFile = staticData.GetNBestFilePath();
-        if ( ! nbestFile.empty() && nbestFile!="-" && !boost::starts_with(nbestFile,"/dev/stdout") ) {
-          boost::filesystem::path nbestPath(nbestFile);
-          weightsFilename << nbestPath.parent_path().filename() << "/weights";
-        } else {
-          weightsFilename << boost::filesystem::current_path().string() << "/hypergraph/weights";
-        }
-      }
-      boost::filesystem::path weightsFilePath(weightsFilename.str());
-      if ( ! boost::filesystem::exists(weightsFilePath.parent_path()) ) {
-        boost::filesystem::create_directory(weightsFilePath.parent_path());
-      }
-      TRACE_ERR("The weights file is " << weightsFilename.str() << "\n");
-      weightsOut->open(weightsFilename.str().c_str());
-      OutputFeatureWeightsForHypergraph(*weightsOut);
-      weightsOut->flush();
-      weightsOut->close();
-      delete weightsOut;
-    }
-
-
-    // initialize output streams
-    // note: we can't just write to STDOUT or files
-    // because multithreading may return sentences in shuffled order
-    auto_ptr<OutputCollector> outputCollector; // for translations
-    auto_ptr<OutputCollector> nbestCollector;  // for n-best lists
-    auto_ptr<OutputCollector> latticeSamplesCollector; //for lattice samples
-    auto_ptr<ofstream> nbestOut;
-    auto_ptr<ofstream> latticeSamplesOut;
-    size_t nbestSize = staticData.GetNBestSize();
-    string nbestFile = staticData.GetNBestFilePath();
-    bool output1best = true;
-    if (nbestSize) {
-      if (nbestFile == "-" || nbestFile == "/dev/stdout") {
-        // nbest to stdout, no 1-best
-        nbestCollector.reset(new OutputCollector());
-        output1best = false;
-      } else {
-        // nbest to file, 1-best to stdout
-        nbestOut.reset(new ofstream(nbestFile.c_str()));
-        if (!nbestOut->good()) {
-          TRACE_ERR("ERROR: Failed to open " << nbestFile << " for nbest lists" << endl);
-          exit(1);
-        }
-        nbestCollector.reset(new OutputCollector(nbestOut.get()));
-      }
-    }
-    size_t latticeSamplesSize = staticData.GetLatticeSamplesSize();
-    string latticeSamplesFile = staticData.GetLatticeSamplesFilePath();
-    if (latticeSamplesSize) {
-      if (latticeSamplesFile == "-" || latticeSamplesFile == "/dev/stdout") {
-        latticeSamplesCollector.reset(new OutputCollector());
-        output1best = false;
-      } else {
-        latticeSamplesOut.reset(new ofstream(latticeSamplesFile.c_str()));
-        if (!latticeSamplesOut->good()) {
-          TRACE_ERR("ERROR: Failed to open " << latticeSamplesFile << " for lattice samples" << endl);
-          exit(1);
-        }
-        latticeSamplesCollector.reset(new OutputCollector(latticeSamplesOut.get()));
-      }
-    }
-    if (output1best) {
-      outputCollector.reset(new OutputCollector());
-    }
-
-    // initialize stream for word graph (aka: output lattice)
-    auto_ptr<OutputCollector> wordGraphCollector;
-    if (staticData.GetOutputWordGraph()) {
-      wordGraphCollector.reset(new OutputCollector(&(ioWrapper->GetOutputWordGraphStream())));
-    }
-
-    // initialize stream for search graph
-    // note: this is essentially the same as above, but in a different format
-    auto_ptr<OutputCollector> searchGraphCollector;
-    if (staticData.GetOutputSearchGraph()) {
-      searchGraphCollector.reset(new OutputCollector(&(ioWrapper->GetOutputSearchGraphStream())));
-    }
-
-    // initialize stram for details about the decoder run
-    auto_ptr<OutputCollector> detailedTranslationCollector;
-    if (staticData.IsDetailedTranslationReportingEnabled()) {
-      detailedTranslationCollector.reset(new OutputCollector(&(ioWrapper->GetDetailedTranslationReportingStream())));
-    }
-
-    // initialize stram for word alignment between input and output
-    auto_ptr<OutputCollector> alignmentInfoCollector;
-    if (!staticData.GetAlignmentOutputFile().empty()) {
-      alignmentInfoCollector.reset(new OutputCollector(ioWrapper->GetAlignmentOutputStream()));
-    }
-
-    //initialise stream for unknown (oov) words
-    auto_ptr<OutputCollector> unknownsCollector;
-    auto_ptr<ofstream> unknownsStream;
-    if (!staticData.GetOutputUnknownsFile().empty()) {
-      unknownsStream.reset(new ofstream(staticData.GetOutputUnknownsFile().c_str()));
-      if (!unknownsStream->good()) {
-        TRACE_ERR("Unable to open " << staticData.GetOutputUnknownsFile() << " for unknowns");
-        exit(1);
-      }
-      unknownsCollector.reset(new OutputCollector(unknownsStream.get()));
+    	if (staticData.IsChart()) {
+    		hypergraphOutputChart.reset(new HypergraphOutput<ChartManager>(PRECISION));
+    	}
+    	else {
+    		hypergraphOutput.reset(new HypergraphOutput<Manager>(PRECISION));
+    	}
     }

 #ifdef WITH_THREADS
@@ -784,45 +202,54 @@
     // main loop over set of input sentences
     InputType* source = NULL;
     size_t lineCount = staticData.GetStartTranslationId();
-    while(ReadInput(*ioWrapper,staticData.GetInputType(),source)) {
+    while(ioWrapper->ReadInput(staticData.GetInputType(),source)) {
+      source->SetTranslationId(lineCount);
       IFVERBOSE(1) {
         ResetUserTime();
       }
+
+      FeatureFunction::CallChangeSource(source);
+
       // set up task of translating one sentence
-      TranslationTask* task =
-        new TranslationTask(lineCount,source, outputCollector.get(),
-                            nbestCollector.get(),
-                            latticeSamplesCollector.get(),
-                            wordGraphCollector.get(),
-                            searchGraphCollector.get(),
-                            detailedTranslationCollector.get(),
-                            alignmentInfoCollector.get(),
-                            unknownsCollector.get(),
-                            staticData.GetOutputSearchGraphSLF(),
-                            staticData.GetOutputSearchGraphHypergraph());
+      TranslationTask* task;
+      if (staticData.IsChart()) {
+    	  // scfg
+          task = new TranslationTask(source, *ioWrapper, hypergraphOutputChart);
+      }
+      else {
+	// pb
+	task = new TranslationTask(source, *ioWrapper,
+				   staticData.GetOutputSearchGraphSLF(),
+				   hypergraphOutput);
+      }
+
       // execute task
 #ifdef WITH_THREADS
+#ifdef PT_UG
       if (my_acnt)
-	{
-	  task->Run();
-	  delete task;
-	  string src,trg,aln;
-	  UTIL_THROW_IF2(!getline(spe_src,src), "[" << HERE << "] "
-			 << "missing update data for simulated post-editing.");
-	  UTIL_THROW_IF2(!getline(spe_trg,trg), "[" << HERE << "] "
-			 << "missing update data for simulated post-editing.");
-	  UTIL_THROW_IF2(!getline(spe_aln,aln), "[" << HERE << "] "
-			 << "missing update data for simulated post-editing.");
-	  BOOST_FOREACH (PhraseDictionary* pd, PhraseDictionary::GetColl())
-	    {
-	      Mmsapt* sapt = dynamic_cast<Mmsapt*>(pd);
-	      if (sapt) sapt->add(src,trg,aln);
-	      VERBOSE(1,"[" << HERE << " added src] " << src << endl);
-	      VERBOSE(1,"[" << HERE << " added trg] " << trg << endl);
-	      VERBOSE(1,"[" << HERE << " added aln] " << aln << endl);
-	    }
-	}
-      else pool.Submit(task);
+      {
+	// simulated post-editing: always run single-threaded!
+        task->Run();
+        delete task;
+        string src,trg,aln;
+        UTIL_THROW_IF2(!getline(spe_src,src), "[" << HERE << "] "
+                       << "missing update data for simulated post-editing.");
+	UTIL_THROW_IF2(!getline(spe_trg,trg), "[" << HERE << "] "
+		       << "missing update data for simulated post-editing.");
+	UTIL_THROW_IF2(!getline(spe_aln,aln), "[" << HERE << "] "
+		       << "missing update data for simulated post-editing.");
+	BOOST_FOREACH (PhraseDictionary* pd, PhraseDictionary::GetColl())
+	  {
+	    Mmsapt* sapt = dynamic_cast<Mmsapt*>(pd);
+	    if (sapt) sapt->add(src,trg,aln);
+	    VERBOSE(1,"[" << HERE << " added src] " << src << endl);
+	    VERBOSE(1,"[" << HERE << " added trg] " << trg << endl);
+	    VERBOSE(1,"[" << HERE << " added aln] " << aln << endl);
+	  }
+      }
+      else
+#endif
+	pool.Submit(task);
 #else
       task->Run();
       delete task;


Fix error detection and cycle detection with autowire

--- include/kangaru/detail/autowire_traits.hpp
+++ include/kangaru/detail/autowire_traits.hpp
@@ -14,6 +14,13 @@
 struct service;

 namespace detail {
+
+template<typename Service1, typename Service2>
+using is_different_service = bool_constant<
+	!std::is_base_of<Service1, Service2>::value &&
+	!std::is_base_of<Service2, Service1>::value
+>;
+
 /*
  * This class is an object convertible to any mapped service.
  * Upon conversion, it calls the container to get that service.
@@ -25,24 +32,24 @@
 	explicit deducer(container& c) noexcept : _container{&c} {}

 	template<typename T, enable_if_t<
-		!std::is_base_of<For, mapped_service_t<T, Map>>::value &&
-		!std::is_base_of<mapped_service_t<T, Map>, For>::value &&
+		is_different_service<For, mapped_service_t<T, Map>>::value &&
+		is_service_valid<mapped_service_t<T, Map>>::value &&
 		!std::is_reference<service_type<mapped_service_t<T, Map>>>::value, int> = 0>
 	operator T () {
 		return _container->service<mapped_service_t<T, Map>>();
 	}

 	template<typename T, enable_if_t<
-		!std::is_base_of<For, mapped_service_t<T&, Map>>::value &&
-		!std::is_base_of<mapped_service_t<T&, Map>, For>::value &&
+		is_different_service<For, mapped_service_t<T&, Map>>::value &&
+		is_service_valid<mapped_service_t<T&, Map>>::value &&
 		std::is_lvalue_reference<service_type<mapped_service_t<T&, Map>>>::value, int> = 0>
 	operator T& () const {
 		return _container->service<mapped_service_t<T&, Map>>();
 	}

 	template<typename T, enable_if_t<
-		!std::is_base_of<For, mapped_service_t<T&&, Map>>::value &&
-		!std::is_base_of<mapped_service_t<T&&, Map>, For>::value &&
+		is_different_service<For, mapped_service_t<T&&, Map>>::value &&
+		is_service_valid<mapped_service_t<T&&, Map>>::value &&
 		std::is_rvalue_reference<service_type<mapped_service_t<T&&, Map>>>::value, int> = 0>
 	operator T&& () const {
 		return _container->service<mapped_service_t<T&&, Map>>();
@@ -52,6 +59,24 @@
 	container* _container;
 };

+template<typename For, typename Map>
+struct weak_deducer {
+	template<typename T, enable_if_t<
+		is_different_service<For, mapped_service_t<T, Map>>::value &&
+		!std::is_reference<service_type<mapped_service_t<T, Map>>>::value, int> = 0>
+	operator T ();
+
+	template<typename T, enable_if_t<
+		is_different_service<For, mapped_service_t<T&, Map>>::value &&
+		std::is_lvalue_reference<service_type<mapped_service_t<T&, Map>>>::value, int> = 0>
+	operator T& () const;
+
+	template<typename T, enable_if_t<
+		is_different_service<For, mapped_service_t<T&&, Map>>::value &&
+		std::is_rvalue_reference<service_type<mapped_service_t<T&&, Map>>>::value, int> = 0>
+	operator T&& () const;
+};
+
 /*
  * Alias that simply add a std::size_t parameter so it can be expanded using a sequence.
  */
@@ -59,6 +84,12 @@
 using deducer_expand_t = deducer<For, Map>;

 /*
+ * Alias that simply add a std::size_t parameter so it can be expanded using a sequence.
+ */
+template<typename For, typename Map, std::size_t>
+using weak_deducer_expand_t = weak_deducer<For, Map>;
+
+/*
  * Trait that check if a service is constructible using `n` amount of deducers.
  */
 template<typename, typename, typename, std::size_t n, typename, typename = typename seq_gen<n>::type, typename = void>
@@ -69,7 +100,7 @@
  * It also returns the injected result of the construct function (assuming a basic construct function)
  */
 template<typename Service, typename T, typename Map, typename... Args, std::size_t... S, std::size_t n>
-struct is_deductible_from_amount_helper<Service, T, Map, n, meta_list<Args...>, seq<S...>, enable_if_t<is_someway_constructible<T, deducer_expand_t<Service, Map, S>..., Args...>::value>> : std::true_type {
+struct is_deductible_from_amount_helper<Service, T, Map, n, meta_list<Args...>, seq<S...>, enable_if_t<is_someway_constructible<T, weak_deducer_expand_t<Service, Map, S>..., Args...>::value>> : std::true_type {
 	using default_result_t = inject_result<deducer_expand_t<Service, Map, S>..., Args...>;
 };


INTEGRATION: CWS helplinker01redux (1.2.2); FILE MERGED 2007/06/16 15:47:33 cmc 1.2.2.1: #i78530# and remove leak

--- xmlhelp/source/com/sun/star/help/HelpCompiler.cxx
+++ xmlhelp/source/com/sun/star/help/HelpCompiler.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: HelpCompiler.cxx,v $
  *
- *  $Revision: 1.2 $
- *
- *  last change: $Author: ihi $ $Date: 2007-06-05 10:24:30 $
+ *  $Revision: 1.3 $
+ *
+ *  last change: $Author: hr $ $Date: 2007-06-26 12:37:53 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -426,6 +426,7 @@

         if (modulename == "DEFAULT")
         {
+            streamTable.dropdefault();
             streamTable.default_doc = docResolvedDoc;
             streamTable.default_hidlist = aparser.hidlist;
             streamTable.default_helptexts = aparser.helptexts;
@@ -433,6 +434,7 @@
         }
         else if (modulename == module)
         {
+            streamTable.dropappl();
             streamTable.appl_doc = docResolvedDoc;
             streamTable.appl_hidlist = aparser.hidlist;
             streamTable.appl_helptexts = aparser.helptexts;


prevent silent failure when there aren't enough distortion weights given with lexicalized reordering models

git-svn-id: f5d636078e73450abf2183305c5e43efec2a5605@1426 1f5c12ca-751b-0410-a591-d2e778427230

--- moses/src/StaticData.cpp
+++ moses/src/StaticData.cpp
@@ -418,6 +418,7 @@
 		{
 			if(w >= weights.size()){
 				//error not enough weights...
+				std::cerr << "Lexicalized distortion model: Not enough weights, add to [weight-d]\n";
 				return false;
 			} else {
 				mweights.push_back(weights[w]);


Make the new override traits work under visual studio 2015

--- include/kangaru/detail/override_traits.hpp
+++ include/kangaru/detail/override_traits.hpp
@@ -19,7 +19,7 @@
  * one override's service definitions can be converted to the service type of the service T definition.
  */
 template<typename Parent, typename T>
-using is_one_override_convertible = is_explicitly_convertible<service_type<T>, detected_t<service_type, Parent>>;
+using is_one_override_convertible = is_explicitly_convertible<detected_t<service_type, T>, detected_t<service_type, Parent>>;

 /*
  * Trait that check if the service type returned by


Added some const reference parameters and comment strings.

--- src/clustering/administration/main/options.hpp
+++ src/clustering/administration/main/options.hpp
@@ -26,7 +26,7 @@
 class names_t {
 public:
     // Include dashes.  For example, name might be "--blah".
-    explicit names_t(std::string name) {
+    explicit names_t(const std::string &name) {
         names.push_back(name);
     }
     // Include the right amount of dashes.  For example, official_name might
@@ -144,7 +144,8 @@
                                                                    const std::string &filepath,
                                                                    const std::vector<option_t> &options);

-
+// A help_line_t is a syntax description and a blurb.  When used in a help_section_t, the blurbs get
+// aligned and word-wrapped.
 struct help_line_t {
     help_line_t(const std::string &_syntax_description,
                 const std::string &_blurb)
@@ -154,6 +155,8 @@
     std::string blurb;
 };

+// A help_section_t is a titled list of syntax descriptions and blurbs.  When rendered with
+// format_help, all the blurbs get aligned and word-wrapped.
 struct help_section_t {
     help_section_t() { }
     help_section_t(const std::string &_section_name)
@@ -169,6 +172,7 @@
     std::vector<help_line_t> help_lines;
 };

+// Creates a help string suitable for output from --help, aligning and word-wrapping the blurbs.
 std::string format_help(const std::vector<help_section_t> &help);


Fixed RTMP starting bug, updated API docs

--- DDV_Controller/main.cpp
+++ DDV_Controller/main.cpp
@@ -257,7 +257,6 @@
   bool seenHTTP = false;
   bool seenRTMP = false;
   std::string tmp;
-  Util::Procs::Stop("RTMP");
   for (Json::ValueIterator jit = p.begin(); jit != p.end(); jit++){
     if (jit.memberName() == std::string("HTTP")){
       tmp = p[jit.memberName()]["port"].asString();


raft: make election_elapsed public for testing

Signed-off-by: Alejo Sanchez <004be06a28e38b437b038f9b5c0b9f5758b792e9@scylladb.com>

--- raft/fsm.hh
+++ raft/fsm.hh
@@ -180,11 +180,6 @@
     bool is_past_election_timeout() const {
         return _clock.now() - _last_election_time >= _randomized_election_timeout;
     }
-    // How much time has passed since last election or last
-    // time we heard from a valid leader.
-    logical_clock::duration election_elapsed() const {
-        return _clock.now() - _last_election_time;
-    }

     // A helper to send any kind of RPC message.
     template <typename Message>
@@ -289,6 +284,12 @@
     // @sa can_read()
     term_t get_current_term() const {
         return _current_term;
+    }
+
+    // How much time has passed since last election or last
+    // time we heard from a valid leader.
+    logical_clock::duration election_elapsed() const {
+        return _clock.now() - _last_election_time;
     }

     // Should be called on leader only, throws otherwise.


+ fix feature caching implementation - collect
  attributes names from all active styles

+ use BOOST_FOREACH to improve readability

 TODO - move 'filter_factor' to raster_symbolizer

git-svn-id: 5adfda8227e14e59fd47d5bd9925a30df16fed74@2056 d397654b-2ff0-0310-9e29-ba003691a0f9

--- include/mapnik/feature_style_processor.hpp
+++ include/mapnik/feature_style_processor.hpp
@@ -40,11 +40,14 @@
 #ifdef MAPNIK_DEBUG
 //#include <mapnik/wall_clock_timer.hpp>
 #endif
+// boost
+#include <boost/foreach.hpp>
 //stl
 #include <vector>

 namespace mapnik
-{
+{
+
 template <typename Processor>
 class feature_style_processor
 {
@@ -87,7 +90,7 @@
         p.start_map_processing(m_);
         Map::const_metawriter_iterator metaItr = m_.begin_metawriters();
         Map::const_metawriter_iterator metaItrEnd = m_.end_metawriters();
-
+
         for (;metaItr!=metaItrEnd; ++metaItr)
         {
             metaItr->second->start();
@@ -101,16 +104,12 @@
 #ifdef MAPNIK_DEBUG
             std::clog << "scale denominator = " << scale_denom << "\n";
 #endif
-            std::vector<layer>::const_iterator itr = m_.layers().begin();
-            std::vector<layer>::const_iterator end = m_.layers().end();
-
-            while (itr != end)
-            {
-                if (itr->isVisible(scale_denom))
-                {
-                    apply_to_layer(*itr, p, proj, scale_denom);
-                }
-                ++itr;
+            BOOST_FOREACH ( layer const& lyr, m_.layers() )
+            {
+                if (lyr.isVisible(scale_denom))
+                {
+                    apply_to_layer(lyr, p, proj, scale_denom);
+                }
             }
         }
         catch (proj_init_error& ex)
@@ -123,7 +122,7 @@
         {
             metaItr->second->stop();
         }
-
+
         p.end_map_processing(m_);
     }
 private:
@@ -168,71 +167,93 @@
             ly0 = std::max(ext.miny(),ly0);
             lx1 = std::min(ext.maxx(),lx1);
             ly1 = std::min(ext.maxy(),ly1);
-
+
             prj_trans.forward(lx0,ly0,lz0);
             prj_trans.forward(lx1,ly1,lz1);
             box2d<double> bbox(lx0,ly0,lx1,ly1);
-
+
             query::resolution_type res(m_.width()/m_.get_current_extent().width(),m_.height()/m_.get_current_extent().height());
             query q(bbox,res,scale_denom); //BBOX query
-
-            std::vector<std::string> const& style_names = lay.styles();
-            std::vector<std::string>::const_iterator stylesIter = style_names.begin();
-            std::vector<std::string>::const_iterator stylesEnd = style_names.end();
+
+            std::vector<feature_type_style*> active_styles;
+            std::set<std::string> names;
+            attribute_collector collector(names);
+
+            std::vector<std::string> const& style_names = lay.styles();
+            // iterate through all named styles collecting active styles and attribute names
+            BOOST_FOREACH(std::string const& style_name, style_names)
+            {
+                boost::optional<feature_type_style const&> style=m_.find_style(style_name);
+                if (!style)
+                {
+                    std::clog << "WARNING: style '" << style_name << "' required for layer '" << lay.name() << "' does not exist.\n";
+                    continue;
+                }
+
+                const std::vector<rule_type>& rules=(*style).get_rules();
+                bool active_rules=false;
+
+                BOOST_FOREACH(rule_type const& rule, rules)
+                {
+                    if (rule.active(scale_denom))
+                    {
+                        active_rules = true;
+                        if (ds->type() == datasource::Vector)
+                        {
+                            collector(rule);
+                        }
+                        // TODO - in the future rasters should be able to be filtered.
+                    }
+                }
+                if (active_rules)
+                {
+                    active_styles.push_back(const_cast<feature_type_style*>(&(*style)));
+                }
+            }
+
+            // push all property names
+            BOOST_FOREACH(std::string const& name, names)
+            {
+                q.add_property_name(name);
+            }
+
             memory_datasource cache;
             bool cache_features = style_names.size()>1?true:false;
             bool first = true;
-            for (;stylesIter != stylesEnd; ++stylesIter)
-            {
-                std::set<std::string> names;
-                attribute_collector collector(names);
+
+            BOOST_FOREACH (feature_type_style * style, active_styles)
+            {
                 std::vector<rule_type*> if_rules;
                 std::vector<rule_type*> else_rules;
-
-                bool active_rules=false;
-
-                boost::optional<feature_type_style const&> style=m_.find_style(*stylesIter);
-                if (!style) {
-                    std::clog << "WARNING: style '" << *stylesIter << "' required for layer '" << lay.name() << "' does not exist.\n";
-                    continue;
-                }
-
-                const std::vector<rule_type>& rules=(*style).get_rules();
-                std::vector<rule_type>::const_iterator ruleIter=rules.begin();
-                std::vector<rule_type>::const_iterator ruleEnd=rules.end();
-
-                for (;ruleIter!=ruleEnd;++ruleIter)
-                {
-                    if (ruleIter->active(scale_denom))
+
+                std::vector<rule_type> const& rules=style->get_rules();
+
+                BOOST_FOREACH(rule_type const& rule, rules)
+                {
+                    if (rule.active(scale_denom))
                     {
-                        active_rules=true;
-                        // collect unique attribute names
-                        // TODO - in the future rasters should be able to be filtered...
-                        if (ds->type() == datasource::Vector)
-                        {
-                            collector(*ruleIter);
-                        }
-                        if (ruleIter->has_else_filter())
-                        {
-                            else_rules.push_back(const_cast<rule_type*>(&(*ruleIter)));
+                        if (rule.has_else_filter())
+                        {
+                            else_rules.push_back(const_cast<rule_type*>(&rule));
                         }
                         else
                         {
-                            if_rules.push_back(const_cast<rule_type*>(&(*ruleIter)));
-                        }
+                            if_rules.push_back(const_cast<rule_type*>(&rule));
+                        }
+
                         if (ds->type() == datasource::Raster)
                         {
                             if (ds->params().get<double>("filter_factor",0.0) == 0.0)
                             {
-                                const rule_type::symbolizers& symbols = ruleIter->get_symbolizers();
+                                rule_type::symbolizers const& symbols = rule.get_symbolizers();
                                 rule_type::symbolizers::const_iterator symIter = symbols.begin();
                                 rule_type::symbolizers::const_iterator symEnd = symbols.end();
                                 for (;symIter != symEnd;++symIter)
                                 {
                                     try
                                     {
-                                        raster_symbolizer sym = boost::get<raster_symbolizer>(*symIter);
-                                        std::string scaling = sym.get_scaling();
+                                        raster_symbolizer const& sym = boost::get<raster_symbolizer>(*symIter);
+                                        std::string const& scaling = sym.get_scaling();
                                         if (scaling == "bilinear" || scaling == "bilinear8" )
                                         {
                                             // todo - allow setting custom value in symbolizer property?
@@ -246,89 +267,70 @@
                                     }
                                 }
                             }
-
                         }
                     }
                 }
-                std::set<std::string>::const_iterator namesIter=names.begin();
-                std::set<std::string>::const_iterator namesEnd =names.end();
-
-                // push all property names
-                for (;namesIter!=namesEnd;++namesIter)
-                {
-                    q.add_property_name(*namesIter);
-                }
-                if (active_rules)
-                {
-                    featureset_ptr fs;
-                    if (first)
-                    {
-                        first = false;
-                        fs = ds->features(q);
+
+                // process features
+                featureset_ptr fs;
+                if (first)
+                {
+                    first = false;
+                    fs = ds->features(q);
+                }
+                else
+                {
+                    fs = cache.features(q);
+                }
+
+                if (fs)
+                {
+                    feature_ptr feature;
+                    while ((feature = fs->next()))
+                    {
+                        bool do_else=true;
+
+                        if (cache_features)
+                        {
+                            cache.push(feature);
+                        }
+
+                        BOOST_FOREACH(rule_type * rule, if_rules )
+                        {
+                            expression_ptr const& expr=rule->get_filter();
+                            value_type result = boost::apply_visitor(evaluate<Feature,value_type>(*feature),*expr);
+                            if (result.to_bool())
+                            {
+                                do_else=false;
+                                rule_type::symbolizers const& symbols = rule->get_symbolizers();
+                                BOOST_FOREACH (symbolizer const& sym, symbols)
+                                {
+                                    boost::apply_visitor
+                                        (symbol_dispatch(p,*feature,prj_trans),sym);
+                                }
+                            }
+                        }
+                        if (do_else)
+                        {
+                            BOOST_FOREACH( rule_type * rule, else_rules )
+                            {
+                                rule_type::symbolizers const& symbols = rule->get_symbolizers();
+                                BOOST_FOREACH (symbolizer const& sym, symbols)
+                                {
+                                    boost::apply_visitor
+                                        (symbol_dispatch(p,*feature,prj_trans),sym);
+                                }
+                            }
+                        }
                     }
-                    else
-                    {
-                        fs = cache.features(q);
-                    }
-                    if (fs)
-                    {
-                        feature_ptr feature;
-                        while ((feature = fs->next()))
-                        {
-                            bool do_else=true;
-
-                            if (cache_features)
-                            {
-                                cache.push(feature);
-                            }
-
-                            std::vector<rule_type*>::const_iterator itr=if_rules.begin();
-                            std::vector<rule_type*>::const_iterator end=if_rules.end();
-                            for (;itr != end;++itr)
-                            {
-                                expression_ptr const& expr=(*itr)->get_filter();
-                                value_type result = boost::apply_visitor(evaluate<Feature,value_type>(*feature),*expr);
-                                if (result.to_bool())
-                                {
-                                    do_else=false;
-                                    const rule_type::symbolizers& symbols = (*itr)->get_symbolizers();
-                                    rule_type::symbolizers::const_iterator symIter=symbols.begin();
-                                    rule_type::symbolizers::const_iterator symEnd =symbols.end();
-                                    for (;symIter != symEnd;++symIter)
-                                    {
-                                        boost::apply_visitor
-                                            (symbol_dispatch(p,*feature,prj_trans),*symIter);
-                                    }
-                                }
-                            }
-                            if (do_else)
-                            {
-                                //else filter
-                                std::vector<rule_type*>::const_iterator itr=
-                                    else_rules.begin();
-                                std::vector<rule_type*>::const_iterator end=
-                                    else_rules.end();
-                                for (;itr != end;++itr)
-                                {
-                                    const rule_type::symbolizers& symbols = (*itr)->get_symbolizers();
-                                    rule_type::symbolizers::const_iterator symIter= symbols.begin();
-                                    rule_type::symbolizers::const_iterator symEnd = symbols.end();
-
-                                    for (;symIter!=symEnd;++symIter)
-                                    {
-                                        boost::apply_visitor
-                                            (symbol_dispatch(p,*feature,prj_trans),*symIter);
-                                    }
-                                }
-                            }
-                        }
-                        cache_features = false;
-                    }
-                }
-            }
-        }
+                    cache_features = false;
+                }
+            }
+        }
+
         p.end_layer_processing(lay);
-    }
+    }
+
     Map const& m_;
     double scale_factor_;
 };


add `const_interior_rings` type and stop abusing type system. (NOTE: iterator/const_iterator types are required by boost::range_iterator)

--- include/mapnik/geometry/boost_adapters.hpp
+++ include/mapnik/geometry/boost_adapters.hpp
@@ -51,6 +51,36 @@
 namespace mapnik {

 template <typename CoordinateType>
+struct const_interior_rings
+{
+    using polygon_type = mapnik::geometry::polygon<CoordinateType> const;
+    using const_iterator = typename polygon_type::const_iterator;
+    using iterator = const_iterator; // needed by boost::range_iterator
+    using value_type = typename polygon_type::value_type;
+
+    const_interior_rings(polygon_type const& poly)
+        : poly_(poly) {}
+
+    const_iterator begin() const
+    {
+        auto itr = poly_.cbegin();
+        std::advance(itr, 1);
+        return itr;
+    }
+
+    const_iterator end() const { return poly_.cend();}
+
+    std::size_t size() const
+    {
+        return poly_.empty() ? 0 : poly_.size() - 1;
+    }
+
+    value_type const& back()  const { return poly_.back(); }
+    polygon_type const& poly_;
+};
+
+
+template <typename CoordinateType>
 struct interior_rings
 {
     using polygon_type = mapnik::geometry::polygon<CoordinateType>;
@@ -71,12 +101,12 @@
     iterator end() { return poly_.end();}
     const_iterator begin() const
     {
-        auto itr = poly_.begin();
+        auto itr = poly_.cbegin();
         std::advance(itr, 1);
         return itr;
     }

-    const_iterator end() const { return poly_.end();}
+    const_iterator end() const { return poly_.cend();}

     void clear()
     {
@@ -183,9 +213,9 @@

 // interior
 template <typename CoordinateType>
-struct interior_const_type<mapnik::geometry::polygon<CoordinateType> >
-{
-    using type = typename mapnik::interior_rings<CoordinateType> const;
+struct interior_const_type<mapnik::geometry::polygon<CoordinateType>>
+{
+    using type = typename mapnik::const_interior_rings<CoordinateType> const;
 };

 template <typename CoordinateType>
@@ -220,7 +250,7 @@

     static interior_const_type get(mapnik::geometry::polygon<CoordinateType> const& p)
     {
-        return mapnik::interior_rings<CoordinateType>(const_cast<mapnik::geometry::polygon<CoordinateType>&>(p));
+        return mapnik::const_interior_rings<CoordinateType>(p);
     }

     static interior_mutable_type get(mapnik::geometry::polygon<CoordinateType>& p)
@@ -257,8 +287,6 @@
     }
 };

-
 }}}

-
 #endif //MAPNIK_BOOST_GEOMETRY_ADAPTERS_HPP


native_types: Fix pendantic error

native_types: Fix pendantic error

Trailing semicolons for function declarations are superfluous.

Change-Id: Ifbf8806b135deccb558bc478b1e6746c9beb9a60
Signed-off-by: William A. Kennington III <30fff5198f4d10ca1117e5f3ec82f3b4b8900d81@google.com>

--- include/sdbusplus/message/native_types.hpp
+++ include/sdbusplus/message/native_types.hpp
@@ -206,7 +206,7 @@
 auto convert_from_string(const std::string& str) noexcept
 {
     return details::convert_from_string<T>::op(str);
-};
+}

 /** @brief Convert from a native type to a string.
  *


remove unsigned warning

remove unsigned warning

--- cpp/src/main/negative_sample_generators/UniformNegativeSampleGenerator.cpp
+++ cpp/src/main/negative_sample_generators/UniformNegativeSampleGenerator.cpp
@@ -14,7 +14,7 @@
     }
     return &samples;
   } else { //no repeating items in the negative sample set
-    for(int i=indices_.size();i<items_->size();i++){
+    for(uint i=indices_.size();i<items_->size();i++){
       indices_.push_back(i);
     }
     int number_of_generated = 0;


Added testGetAllDocumentsFromTwoCollections

--- tests/Queries/tst_QueriesTest.cpp
+++ tests/Queries/tst_QueriesTest.cpp
@@ -51,6 +51,16 @@
     doc3->save();

     driver.waitUntilFinished(doc1, doc2, doc3);
+
+    arangodb::Document * doc4 = temp2Collection->createDocument();
+    doc4->set("con", doc1->docID());
+    arangodb::Document * doc5 = temp2Collection->createDocument();
+    doc5->set("con", doc2->docID());
+
+    doc4->save();
+    doc5->save();
+
+    driver.waitUntilFinished(doc4, doc5);
 }

 QueriesTest::~QueriesTest()
@@ -149,6 +159,30 @@
 void QueriesTest::testGetAllDocumentsFromTwoCollections()
 {
     auto select = qb.createSelect(tempCollection->name(), 2);
+    select->addNewCollection(temp2Collection->name());
+
+    QCOMPARE(select->collections().size(), 2);
+    QCOMPARE(select->collections().at(0), QStringLiteral("temp"));
+    QCOMPARE(select->collections().at(1), QStringLiteral("temp2"));
+
+    auto cursor = driver.executeSelect(select);
+    cursor->waitForResult();
+
+    QVERIFY2(cursor->hasErrorOccurred() == false, cursor->errorMessage().toLocal8Bit());
+    QCOMPARE(cursor->hasMore(), true);
+
+    cursor->getMoreData();
+    cursor->waitForResult();
+
+    QVERIFY2(cursor->hasErrorOccurred() == false, cursor->errorMessage().toLocal8Bit());
+    QCOMPARE(cursor->hasMore(), true);
+
+    cursor->getMoreData();
+    cursor->waitForResult();
+
+    QVERIFY2(cursor->hasErrorOccurred() == false, cursor->errorMessage().toLocal8Bit());
+    QCOMPARE(cursor->hasMore(), false);
+    QCOMPARE(cursor->data().size(), 5);
 }

 QTEST_MAIN(QueriesTest)


fixes issue 746
+ dos2unix on ole_tests_win.cpp
+ fix build error for ole_tests_win.cpp with VS2005

git-svn-id: fe3cd4388a6e5a968b09397a3d721fe124e8117a@703 5b54908e-ead4-fc18-b48a-0285e6dbc711

--- tests/app_suite/ole_tests_win.cpp
+++ tests/app_suite/ole_tests_win.cpp
@@ -1,62 +1,66 @@
-/* **********************************************************
- * Copyright (c) 2012 Google, Inc.  All rights reserved.
- * **********************************************************/
-
-/* Dr. Memory: the memory debugger
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License, and no later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <windows.h>
-#include <objbase.h>
-#include <stdlib.h>
-
-// For shell link stuff.
-#include <shobjidl.h>
-#include <shlguid.h>
-
-#pragma comment(lib, "ole32.lib")
-
-#include "gtest/gtest.h"
-
-// Ensure that CoInitializeEx test comes first, because many of the leaks
-// happen once per process, and the callstacks through CoInitializeEx are
-// harder to suppress due its tail call.
-TEST(OleTest, CoInitializeEx) {
-    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
-    ASSERT_TRUE(SUCCEEDED(hr));
-    CoUninitialize();
-}
-
-TEST(OleTest, CoInitialize) {
-    HRESULT hr = CoInitialize(NULL);
-    ASSERT_TRUE(SUCCEEDED(hr));
-    CoUninitialize();
-}
-
-TEST(OleTest, CoCreateInstance) {
-    HRESULT hr = CoInitialize(NULL);
-    ASSERT_TRUE(SUCCEEDED(hr));
-
-    // Some COM object for creating shortcut files.  We just use it as an
-    // arbitrary object that we can create.
-    IShellLink* shell_link = NULL;
-    hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
-                          IID_IShellLink, (LPVOID*)&shell_link);
-    ASSERT_TRUE(SUCCEEDED(hr));
-    shell_link->Release();
-
-    CoUninitialize();
-}
+/* **********************************************************
+ * Copyright (c) 2012 Google, Inc.  All rights reserved.
+ * **********************************************************/
+
+/* Dr. Memory: the memory debugger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License, and no later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#if _MSC_VER <= 1400
+# define _WIN32_WINNT 0x0400 /* == NT4 */ /* not set for VS2005 */
+#endif
+
+#include <windows.h>
+#include <objbase.h>
+#include <stdlib.h>
+
+// For shell link stuff.
+#include <shobjidl.h>
+#include <shlguid.h>
+
+#pragma comment(lib, "ole32.lib")
+
+#include "gtest/gtest.h"
+
+// Ensure that CoInitializeEx test comes first, because many of the leaks
+// happen once per process, and the callstacks through CoInitializeEx are
+// harder to suppress due its tail call.
+TEST(OleTest, CoInitializeEx) {
+    HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+    ASSERT_TRUE(SUCCEEDED(hr));
+    CoUninitialize();
+}
+
+TEST(OleTest, CoInitialize) {
+    HRESULT hr = CoInitialize(NULL);
+    ASSERT_TRUE(SUCCEEDED(hr));
+    CoUninitialize();
+}
+
+TEST(OleTest, CoCreateInstance) {
+    HRESULT hr = CoInitialize(NULL);
+    ASSERT_TRUE(SUCCEEDED(hr));
+
+    // Some COM object for creating shortcut files.  We just use it as an
+    // arbitrary object that we can create.
+    IShellLink* shell_link = NULL;
+    hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+                          IID_IShellLink, (LPVOID*)&shell_link);
+    ASSERT_TRUE(SUCCEEDED(hr));
+    shell_link->Release();
+
+    CoUninitialize();
+}


[tests.elliptic-discretizations] reenabled sipdg

--- tests/elliptic-discretizations.cc
+++ tests/elliptic-discretizations.cc
@@ -27,7 +27,7 @@

 #include "elliptic-testcases.hh"
 #include "elliptic-cg-discretization.hh"
-//#include "elliptic-sipdg-discretization.hh"
+#include "elliptic-sipdg-discretization.hh"
 //#include "elliptic-swipdg-discretization.hh"

 class errors_are_not_as_expected : public Dune::Exception
@@ -82,44 +82,41 @@
   }
 }; // EllipticCGDiscretization

-// template< class TestCase >
-// struct EllipticSIPDGDiscretization
-//  : public ::testing::Test
-//{
-//  void produces_correct_results() const
-//  {
-//    if (std::is_same< TestCase, EllipticTestCase::Spe10Model1< Dune::ALUConformGrid< 2, 2 > > >::value) {
-//      std::cerr
-//          << Dune::Stuff::Common::colorStringRed("EllipticSIPDGDiscretization does not work for "
-//                                                 "EllipticTestCase::Spe10Model1< Dune::ALUConformGrid< 2, 2 > >!")
-//          << std::endl;
-//    } else {
-//      const TestCase test_case;
-//      test_case.print_header(test_out);
-//      test_out << std::endl;
-//      EllipticSIPDG::EocStudy< TestCase, 1 > eoc_study_1(test_case);
-//      auto errors_1 = eoc_study_1.run(test_out);
-//      for (const auto& norm : eoc_study_1.provided_norms()) {
-//        if (!Dune::Stuff::Common::FloatCmp::lt(errors_1[norm], eoc_study_1.expected_results(norm))) {
-//          std::stringstream ss;
-//          Dune::Stuff::Common::print(errors_1[norm],                     "errors           (" + norm + ")", ss);
-//          Dune::Stuff::Common::print(eoc_study_1.expected_results(norm), "   expected results (" + norm + ")", ss);
-//          DUNE_THROW_COLORFULLY(errors_are_not_as_expected, ss.str());
-//        }
-//      }
-//      test_out << std::endl;
-//      EllipticSIPDG::EocStudy< TestCase, 2 > eoc_study_2(test_case);
-//      auto errors_2 = eoc_study_2.run(test_out);
-//      for (const auto& norm : eoc_study_2.provided_norms())
-//        if (!Dune::Stuff::Common::FloatCmp::lt(errors_2[norm], eoc_study_2.expected_results(norm))) {
-//          std::stringstream ss;
-//          Dune::Stuff::Common::print(errors_2[norm],                     "errors           (" + norm + ")", ss);
-//          Dune::Stuff::Common::print(eoc_study_2.expected_results(norm), "   expected results (" + norm + ")", ss);
-//          DUNE_THROW_COLORFULLY(errors_are_not_as_expected, ss.str());
-//        }
-//    }
-//  }
-//}; // EllipticSIPDGDiscretization
+template <class TestCase>
+struct EllipticSIPDGDiscretization : public ::testing::Test
+{
+  void produces_correct_results() const
+  {
+    if (std::is_same<TestCase, EllipticTestCase::Spe10Model1<Dune::ALUConformGrid<2, 2>>>::value) {
+      std::cerr << Dune::Stuff::Common::colorStringRed("EllipticSIPDGDiscretization does not work for "
+                                                       "EllipticTestCase::Spe10Model1< Dune::ALUConformGrid< 2, 2 > >!")
+                << std::endl;
+    } else {
+      const TestCase test_case;
+      test_case.print_header(test_out);
+      test_out << std::endl;
+      EllipticSIPDG::EocStudy<TestCase, 1> eoc_study_1(test_case);
+      auto errors_1 = eoc_study_1.run(test_out);
+      for (const auto& norm : eoc_study_1.provided_norms())
+        if (!Dune::Stuff::Common::FloatCmp::lt(errors_1[norm], eoc_study_1.expected_results(norm))) {
+          std::stringstream ss;
+          Dune::Stuff::Common::print(errors_1[norm], "errors           (" + norm + ")", ss);
+          Dune::Stuff::Common::print(eoc_study_1.expected_results(norm), "   expected results (" + norm + ")", ss);
+          DUNE_THROW_COLORFULLY(errors_are_not_as_expected, ss.str());
+        }
+      test_out << std::endl;
+      EllipticSIPDG::EocStudy<TestCase, 2> eoc_study_2(test_case);
+      auto errors_2 = eoc_study_2.run(test_out);
+      for (const auto& norm : eoc_study_2.provided_norms())
+        if (!Dune::Stuff::Common::FloatCmp::lt(errors_2[norm], eoc_study_2.expected_results(norm))) {
+          std::stringstream ss;
+          Dune::Stuff::Common::print(errors_2[norm], "errors           (" + norm + ")", ss);
+          Dune::Stuff::Common::print(eoc_study_2.expected_results(norm), "   expected results (" + norm + ")", ss);
+          DUNE_THROW_COLORFULLY(errors_are_not_as_expected, ss.str());
+        }
+    }
+  }
+}; // EllipticSIPDGDiscretization

 // template< class TestCase >
@@ -161,10 +158,11 @@
   this->produces_correct_results();
 }

-// TYPED_TEST_CASE(EllipticSIPDGDiscretization, AluConform2dTestCases);
-// TYPED_TEST(EllipticSIPDGDiscretization, produces_correct_results) {
-//  this->produces_correct_results();
-//}
+TYPED_TEST_CASE(EllipticSIPDGDiscretization, AluConform2dTestCases);
+TYPED_TEST(EllipticSIPDGDiscretization, produces_correct_results)
+{
+  this->produces_correct_results();
+}

 // TYPED_TEST_CASE(EllipticSWIPDGDiscretization, AluConform2dTestCases);
 // TYPED_TEST(EllipticSWIPDGDiscretization, produces_correct_results) {


updating the includes to use with a tracked vehicle demo

--- src/demos/trackedVehicle/demo_tracked_M113.cpp
+++ src/demos/trackedVehicle/demo_tracked_M113.cpp
@@ -22,50 +22,128 @@

 #include "physics/ChSystem.h"
-#include "particlefactory/ChParticleEmitter.h"
+// #include "particlefactory/ChParticleEmitter.h"
+
+
+#include "core/ChFileutils.h"
+#include "core/ChStream.h"
+#include "core/ChRealtimeStep.h"
+#include "physics/ChSystem.h"
+#include "physics/ChLinkDistance.h"
+
+#include "utils/ChUtilsInputOutput.h"
+#include "utils/ChUtilsData.h"
 #include "assets/ChTexture.h"
 #include "assets/ChColorAsset.h"
+/*
+#if IRRLICHT_ENABLED
+*/
 #include "unit_IRRLICHT/ChIrrApp.h"
 #include "subsys/driver/ChIrrGuiTrack.h"
-
+ /*
+ # define USE_IRRLICHT
+#endif
+ */
 #include "subsys/trackVehicle/trackVehicle.h"

-// Use the main namespace of Chrono, and other chrono namespaces
-
+// Use the main namespace of Chrono
 using namespace chrono;
-using namespace chrono::geometry;

 // Use the main namespaces of Irrlicht
 using namespace irr;
 using namespace core;
-using namespace scene;
-using namespace video;
-using namespace io;
-using namespace gui;
-
-#include <irrlicht.h>
+
+
+// // Initial vehicle position
+ChVector<> initLoc(0, 1.0, 0);
+// Initial vehicle orientation
+ChQuaternion<> initRot(1, 0, 0, 0);
+//ChQuaternion<> initRot(0.866025, 0, 0, 0.5);
+//ChQuaternion<> initRot(0.7071068, 0, 0, 0.7071068);
+//ChQuaternion<> initRot(0.25882, 0, 0, 0.965926);
+//ChQuaternion<> initRot(0, 0, 0, 1);
+
+// Simulation step size
+double step_size = 0.001;
+
+// Time interval between two render frames
+int FPS = 50;
+double render_step_size = 1.0 / FPS;   // FPS = 50
+
+// #ifdef USE_IRRLICHT
+  // Point on chassis tracked by the camera
+  ChVector<> trackPoint(0.0, 0.0, .75);
+  /*
+#else
+  double tend = 20.0;
+
+  const std::string out_dir = "../HMMWV9";
+  const std::string pov_dir = out_dir + "/POVRAY";
+#endif
+  */

 int main(int argc, char* argv[])
 {
-  // no system to create, it's in the trackVehicle
-
-	// ..the tank (this class - see above - is a 'set' of bodies and links, automatically added at creation)
+
+  // no system to create, it's in the TrackVehicle
 	TrackVehicle vehicle("name");

+  vehicle.Initialize(ChCoordsys<>(initLoc, initRot));
+
+/*
+#ifdef USE_IRRLICHT
+*/
 	// Create the Irrlicht visualization applicaiton
-	ChIrrApp application(&vehicle, L"Modeling a simplified   tank",core::dimension2d<u32>(800,600),false, true);
-
-
-	// Easy shortcuts to add logo, camera, lights and sky in Irrlicht scene:
-	ChIrrWizard::add_typical_Logo(application.GetDevice());
-	ChIrrWizard::add_typical_Sky(application.GetDevice());
-	ChIrrWizard::add_typical_Lights(application.GetDevice());
-	ChIrrWizard::add_typical_Camera(application.GetDevice(), core::vector3df(0,0,-6), core::vector3df(-2,2,0));
-
+  ChIrrApp application(&vehicle,
+                      L"HMMWV 9-body demo",
+                      dimension2d<u32>(1000, 800),
+                      false,
+                      true);

+  // make a skybox that has Z pointing up (default application.AddTypicalSky() makes Y up)
+  std::string mtexturedir = GetChronoDataFile("skybox/");
+  std::string str_lf = mtexturedir + "sky_lf.jpg";
+  std::string str_up = mtexturedir + "sky_up.jpg";
+  std::string str_dn = mtexturedir + "sky_dn.jpg";
+  irr::video::ITexture* map_skybox_side =
+      application.GetVideoDriver()->getTexture(str_lf.c_str());
+  irr::scene::ISceneNode* mbox = application.GetSceneManager()->addSkyBoxSceneNode(
+      application.GetVideoDriver()->getTexture(str_up.c_str()),
+      application.GetVideoDriver()->getTexture(str_dn.c_str()),
+      map_skybox_side,
+      map_skybox_side,
+      map_skybox_side,
+      map_skybox_side);
+  mbox->setRotation( irr::core::vector3df(0,0,0));
+
+  bool do_shadows = true; // shadow map is experimental
+  irr::scene::ILightSceneNode* mlight = 0;
+
+  if (do_shadows)
+  {
+    mlight = application.AddLightWithShadow(
+      irr::core::vector3df(10.f, 30.f, 60.f),
+      irr::core::vector3df(0.f, 0.f, 0.f),
+      150, 60, 80, 15, 512, irr::video::SColorf(1, 1, 1), false, false);
+  }
+  else
+  {
+    application.AddTypicalLights(
+      irr::core::vector3df(30.f, -30.f, 100.f),
+      irr::core::vector3df(30.f, 50.f, 100.f),
+      250, 130);
+  }
+
+  application.SetTimestep(step_size);
+
+  ChIrrGuiTrack driver();
+
+
+
+
 	// ground plate
   ChSharedPtr<ChBody> ground(new ChBodyEasyBox(60.0, 1.0, 100.0, 1000.0, true, true);


fix according to code review of #276

fix according to code review of #276

--- src/dist/failure_detector/failure_detector.cpp
+++ src/dist/failure_detector/failure_detector.cpp
@@ -417,18 +417,6 @@
         return true;
     }

-    /*
-     * TODO(qinzuoyan): event if the remote is not master, we still treat it as master to avoid
-     * lease timeout, which may cause this server unavailable.
-     *
-    if (!ack.is_master)
-    {
-        dwarn("remote node[%s] is not master, ack.primary_node[%s]",
-              node.to_string(), ack.primary_node.to_string());
-        return true;
-    }
-    */
-
     // update last_send_time_for_beacon_with_ack
     record.last_send_time_for_beacon_with_ack = beacon_send_time;
     record.rejected = false;


[grid] adds GridWalk generator function

[grid] adds GridWalk generator function

--- dune/stuff/grid/walk.hh
+++ dune/stuff/grid/walk.hh
@@ -100,6 +100,12 @@
   this->operator()(f);
 }

+//!
+template <class ViewImp, int codim = 0>
+GridWalk< Dune::GridView<ViewImp>, codim > make_gridwalk(const Dune::GridView<ViewImp>& view) {
+    return GridWalk< Dune::GridView<ViewImp>, codim >(view);
+}
+
 } // namespace Grid
 } // namespace Stuff
 } // namespace Dune


added parameter for tool DockPoseClustering

parameter o_dcd allows to store a DCDFile with one cluster representative per cluster

--- source/APPLICATIONS/TOOLS/DockPoseClustering.C
+++ source/APPLICATIONS/TOOLS/DockPoseClustering.C
@@ -36,13 +36,15 @@
 	// - description
 	// - Outputfile
 	// - required
-	parpars.registerParameter("o", "output dcd-file name for first solution", STRING, true, "", true);
+	parpars.registerParameter("o", "output dcd-file name for first solution ", STRING, true, "", true);

-	parpars.registerParameter("o_id", "output id", STRING, true, "", true);
+	parpars.registerParameter("o_id", "output id ", STRING, true, "", true);

-	parpars.registerParameter("o_dir", "output directory for 2nd to last solution", STRING, true, "", true);
+	parpars.registerParameter("o_dir", "output directory for 2nd to last solution ", STRING, true, "", true);

-	// register String parameter for supplying max number of solutions
+	parpars.registerParameter("o_dcd", "output directory for the reduced cluster set (one structure per final cluster) ", STRING, false, "", true);
+
+	// register String parameter for supplying minimal rmsd between clusters
 	parpars.registerParameter("rmsd_cutoff", "minimal rmsd between the final clusters (default 5.0) ", DOUBLE, false, 5.0);
 	parpars.setParameterRestrictions("rmsd_cutoff", 0, 100);

@@ -57,14 +59,15 @@
 	parpars.setParameterRestrictions("rmsd_scope", rmsd_levels);

   // the manual
-	String man = "This tool computes clusters of docking poses given as conformation set using a complete linkage algorithm.\n\nParameters are the input ConformationSet (-i_dcd), one corresponding pdb file (-i_pdb) and a naming schema for the results (-o). Optional parameters the minimal rmsd between the final clusters  (-rmsd_cutoff) and the scope/level of detail of the rmsd computation (-rmsd_scope).\n\nOutput of this tool is a number of dcd files each containing one ConformationSet.";
+	String man = "This tool computes clusters of docking poses given as conformation set using a complete linkage algorithm.\n\nParameters are the input ConformationSet (-i_dcd), one corresponding pdb file (-i_pdb) and a naming schema for the results (-o). Optional parameters are the minimal rmsd between the final clusters  (-rmsd_cutoff) and the scope/level of detail of the rmsd computation (-rmsd_scope). The optional parameter (-o_dcd)\n\nOutput of this tool is a number of dcd files each containing one ConformationSet.";

 	parpars.setToolManual(man);

-	// here we set the types of I/O files, for example sdf is also allowed
+	// here we set the types of I/O files
 	parpars.setSupportedFormats("i_dcd","dcd");
 	parpars.setSupportedFormats("i_pdb","pdb");
 	parpars.setSupportedFormats("o","dcd");
+	parpars.setSupportedFormats("o_dcd","dcd");

 	parpars.parse(argc, argv);

@@ -118,13 +121,15 @@
 			                               + String(parpars.get("o_id"))  + "_cluster" + String(i)
 			                               + "_visible_dcd";
 		//Log << "   Writing solution " << String(i) << " as " << outfile_name << endl;
-		//	GenericMolFile* outfile = MolFileFactory::open(outfile_name, ios::out);
-
-		//DCD2File outfile(outfile_name, ios::out);
-		//outfile << new_cs;
-		//outfile.close();

 		new_cs->writeDCDFile(outfile_name);
+	}
+
+	if (parpars.has("o_dcd"))
+	{
+		String outfile_name = String(parpars.get("o_dcd"));
+		boost::shared_ptr<ConformationSet> cs = pc.getReducedConformationSet();
+		cs->writeDCDFile(outfile_name);
 	}

 	Log << "done." << endl;


WaE: expression result unused

WaE: expression result unused

--- formula/source/core/api/FormulaCompiler.cxx
+++ formula/source/core/api/FormulaCompiler.cxx
@@ -271,7 +271,7 @@
 {
     bool bOk = mpReverseExternalHashMap->insert( ExternalHashMap::value_type( rAddIn, rSymbol)).second;
     if (bOk)
-        mpExternalHashMap->insert( ExternalHashMap::value_type( rSymbol, rAddIn)).second;
+        mpExternalHashMap->insert( ExternalHashMap::value_type( rSymbol, rAddIn));
 }
 uno::Sequence< sheet::FormulaToken > FormulaCompiler::OpCodeMap::createSequenceOfFormulaTokens(const FormulaCompiler& _rCompiler,const uno::Sequence< ::rtl::OUString >& rNames ) const
 {


added guard

added guard

--- core/ilwisobjects/coverage/featureiterator.cpp
+++ core/ilwisobjects/coverage/featureiterator.cpp
@@ -103,7 +103,9 @@
 {
     if ( _isInitial)     {
         _isInitial = false;
-        _fcoverage->connector()->loadBinaryData(_fcoverage.ptr());
+        bool ok = _fcoverage->connector()->loadBinaryData(_fcoverage.ptr());
+        if (!ok)
+            return false;
         if ( _fcoverage->_features.size() > 0 ) {
             _iterFeatures = _fcoverage->_features.begin();
             _trackCounter = 0;


[vm] Fix CreateWithinExistingIsolateGroup calling RegisterIsolate without a write lock.

Detected by TSAN as a data race between the registration code and iteration code.

Bug: https://github.com/dart-lang/sdk/issues/39611
Change-Id: Ic232e9382a775369ce5898f3c4e5a90e8c0160c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139495
Reviewed-by: Martin Kustermann <a35dd5b79fac84b2bb3b026a16b8becc55af5961@google.com>
Commit-Queue: Ryan Macnak <d738b7f001baf9789095d7dc549cff6de60b011d@google.com>

--- runtime/vm/isolate.cc
+++ runtime/vm/isolate.cc
@@ -267,7 +267,7 @@
 }

 void IsolateGroup::RunWithLockedGroup(std::function<void()> fun) {
-  SafepointReadRwLocker ml(Thread::Current(), isolates_lock_.get());
+  SafepointWriteRwLocker ml(Thread::Current(), isolates_lock_.get());
   fun();
 }


clean-up

clean-up

--- ferocious/mainwindow.cpp
+++ ferocious/mainwindow.cpp
@@ -336,7 +336,7 @@
         ui->OutfileLabel->setText("Output File:");
         ui->OutfileEdit->setReadOnly(false);
         filenameSpec=fileNames.first();
-        if(!filenameSpec.isNull()){
+        if(!filenameSpec.isNull()) {

             ui->InfileEdit->setText(QDir::toNativeSeparators(filenameSpec));

@@ -351,7 +351,7 @@
                 bRefreshOutFilename = true;

             // conditionally auto-generate output filename:
-            if(bRefreshOutFilename){
+            if(bRefreshOutFilename) {
                 QString outFileName;
                 filenameGenerator.generateOutputFilename(outFileName,ui->InfileEdit->text());
                 if(!outFileName.isNull() && !outFileName.isEmpty())
@@ -370,7 +370,7 @@
         }

         ui->InfileEdit->setText(filenameSpec);
-        QString firstFile =  QDir::toNativeSeparators(fileNames.first()); // get first filename in list (use to generate output filename)
+        QString firstFile = QDir::toNativeSeparators(fileNames.first()); // get first filename in list (use to generate output filename)

         QString outFilename=firstFile; // use first filename as a basis for generating output filename
         int LastDot = outFilename.lastIndexOf(".");
@@ -483,7 +483,7 @@

     // initialize output file extension:
     int outLastDot = ui->OutfileEdit->text().lastIndexOf(".");
-    if(outLastDot > -1){
+    if(outLastDot > -1) {
         O.fileExt = ui->OutfileEdit->text().right(ui->OutfileEdit->text().length()-outLastDot-1); // get file extension from file nam
         if(O.fileExt.lastIndexOf("*")>-1){ // outfile extension has a wildcard in it
             O.useSpecificFileExt = false;   // use source file extension
@@ -497,7 +497,7 @@
     // initialize output file suffix:
     // (use whatever is between last '*' and '.')
     int outLastStarBeforeDot = ui->OutfileEdit->text().left(outLastDot).lastIndexOf("*");
-    if(outLastStarBeforeDot > -1){
+    if(outLastStarBeforeDot > -1) {
         O.Suffix = ui->OutfileEdit->text().mid(outLastStarBeforeDot+1,outLastDot-outLastStarBeforeDot-1); // get what is between last '*' and last '.'
         O.appendSuffix = true;
     } else { // no Suffix
@@ -985,7 +985,6 @@
 void MainWindow::on_actionEnable_Clipping_Protection_triggered()
 {
     bDisableClippingProtection = !ui->actionEnable_Clipping_Protection->isChecked();
-    qDebug() << bDisableClippingProtection;
 }

 void MainWindow::applyStylesheet() {


Add reference to html page explaining the particle convention (Babar web site).

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@3275 27541ba8-7e3a-0410-8455-c3a389f83636

--- eg/src/TDatabasePDG.cxx
+++ eg/src/TDatabasePDG.cxx
@@ -1,4 +1,4 @@
-// @(#)root/eg:$Name:  $:$Id: TDatabasePDG.cxx,v 1.15 2001/11/06 19:15:13 rdm Exp $
+// @(#)root/eg:$Name:  $:$Id: TDatabasePDG.cxx,v 1.16 2001/11/22 07:38:22 brun Exp $
 // Author: Pasha Murat   12/02/99

 #ifdef HAVE_CONFIG
@@ -217,7 +217,7 @@
   //
   //Begin_Html
   /*
-   http://www.slac.stanford.edu/BFROOT/www/Computing/Environment/NewUser/htmlbug/node51.html
+   see  Conversion table
   */
   //End_Html
   // with some fixes by PB, marked with (PB) below. Checked against


Disable JingleSessionTest.Connect, JingleSessionTest.TestControlChannel

Those tests flakily trigger a libjingle assertion:

Error(common.cc:67): e:\b\build\slave\win\build\src\third_party\libjingle\source\talk\session\tunnel\pseudotcpchannel.cc(281): ASSERT FAILED: stream_ != NULL && stream_thread_->IsCurrent() @ cricket::PseudoTcpChannel::Close

TBR=hclam

BUG=70225
TEST=remoting_unittests
Review URL: http://codereview.chromium.org/6334046

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@73436 0039d316-1c4b-4281-b951-d872f2087c98

--- remoting/protocol/jingle_session_unittest.cc
+++ remoting/protocol/jingle_session_unittest.cc
@@ -586,13 +586,15 @@
 }

 // Verify that we can connect two endpoints.
-TEST_F(JingleSessionTest, Connect) {
+// Disabled, http://crbug.com/70225.
+TEST_F(JingleSessionTest, DISABLED_Connect) {
   CreateServerPair();
   ASSERT_TRUE(InitiateConnection());
 }

 // Verify that data can be transmitted over the event channel.
-TEST_F(JingleSessionTest, TestControlChannel) {
+// Disabled, http://crbug.com/70225.
+TEST_F(JingleSessionTest, DISABLED_TestControlChannel) {
   CreateServerPair();
   ASSERT_TRUE(InitiateConnection());
   scoped_refptr<TCPChannelTester> tester(


- fixed color switch bug in OpenGL when using ColoredTexturedVertex directly

--- rendersystems/OpenGL/OpenGL_RenderSystem.cpp
+++ rendersystems/OpenGL/OpenGL_RenderSystem.cpp
@@ -506,7 +506,7 @@
 		glDrawArrays(gl_render_ops[renderOp], 0, nVertices);
 	}

-	void OpenGL_RenderSystem::render(RenderOp renderOp,PlainVertex* v, int nVertices, Color color)
+	void OpenGL_RenderSystem::render(RenderOp renderOp, PlainVertex* v, int nVertices, Color color)
 	{
 		if (mTexCoordsEnabled)
 		{
@@ -524,8 +524,8 @@
 #else
 		if (!mColorEnabled)
 		{
+			mColorEnabled = true;
 			glEnableClientState(GL_COLOR_ARRAY);
-			mColorEnabled = true;
 		}
 		GLuint colors[nVertices];
 		GLbyte colorB[4] = {(GLbyte)color.r, (GLbyte)color.g, (GLbyte)color.b, (GLbyte)color.a};
@@ -576,8 +576,22 @@
 		}
 #if !(TARGET_OS_IPHONE) && !(_OPENGLES1)
 		glColor4f(1, 1, 1, 1);
+#else
+		GLuint colors[nVertices];
+		GLbyte colorB[4] = {(GLbyte)color.r, (GLbyte)color.g, (GLbyte)color.b, (GLbyte)color.a};
+		GLuint _color = *(GLuint*)colorB;
+		for (int i = 0; i < nVertices; i++)
+		{
+			colors[i] = _color;
+		}
+		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(color), colors);
 #endif
 		glVertexPointer(3, GL_FLOAT, sizeof(ColoredTexturedVertex), v);
+		for (int i = 0; i < nVertices; i++)
+		{
+			// making sure this is in AGBR order
+			v[i].color = (((v[i].color & 0xFF000000) >> 24) | ((v[i].color & 0x00FF0000) >> 8) | ((v[i].color & 0x0000FF00) << 8) | ((v[i].color & 0x000000FF) << 24));
+		}
 		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ColoredTexturedVertex), &v->color);
 		glTexCoordPointer(2, GL_FLOAT, sizeof(ColoredTexturedVertex), &v->u);
 		glDrawArrays(gl_render_ops[renderOp], 0, nVertices);


test: extend mutation_test for NULL values

The test is extended for another possible corner case:
[1, NULL, 2] vs [1, 2, NULL] should have different digests.
Also, a check for legacy behavior is added.

--- test/boost/mutation_test.cc
+++ test/boost/mutation_test.cc
@@ -3057,8 +3057,18 @@
     r2.append_cell(0, atomic_cell::make_live(*bytes_type, 1, bytes{}));
     r2.append_cell(2, atomic_cell::make_live(*bytes_type, 1, to_bytes("bbb")));

+    auto r3 = row();
+    r3.append_cell(0, atomic_cell::make_live(*bytes_type, 1, bytes{}));
+    r3.append_cell(1, atomic_cell::make_live(*bytes_type, 1, to_bytes("bbb")));
+
     BOOST_CHECK(!r1.equal(column_kind::regular_column, *s, r2, *s));

+    auto compute_legacy_hash = [&] (const row& r, const query::column_id_vector& columns) {
+        auto hasher = legacy_xx_hasher_without_null_digest{};
+        max_timestamp ts;
+        appending_hash<row>{}(hasher, r, *s, column_kind::regular_column, columns, ts);
+        return hasher.finalize_uint64();
+    };
     auto compute_hash = [&] (const row& r, const query::column_id_vector& columns) {
         auto hasher = xx_hasher{};
         max_timestamp ts;
@@ -3070,4 +3080,10 @@
     BOOST_CHECK_EQUAL(compute_hash(r1, { 0, 1 }), compute_hash(r2, { 0, 1 }));
     BOOST_CHECK_NE(compute_hash(r1, { 0, 2 }), compute_hash(r2, { 0, 2 }));
     BOOST_CHECK_NE(compute_hash(r1, { 0, 1, 2 }), compute_hash(r2, { 0, 1, 2 }));
-}
+    // Additional test for making sure that {"", NULL, "bbb"} is not equal to {"", "bbb", NULL}
+    // due to ignoring NULL in a hash
+    BOOST_CHECK_NE(compute_hash(r2, { 0, 1, 2 }), compute_hash(r3, { 0, 1, 2 }));
+    // Legacy check which shows incorrect handling of NULL values.
+    // These checks are meaningful because legacy hashing is still used for old nodes.
+    BOOST_CHECK_EQUAL(compute_legacy_hash(r1, { 0, 1, 2 }), compute_legacy_hash(r2, { 0, 1, 2 }));
+}


Plug some memory leaks in parser tests.

Plug some memory leaks in parser tests.

BUG=v8:2763
R=dslomov@chromium.org

Review URL: https://codereview.chromium.org/18694004

Patch from Sergey Matveev <earthdok@chromium.org>.

git-svn-id: b158db1e4b4ab85d4c9e510fdef4b1e8c614b15b@15490 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

--- test/cctest/test-parsing.cc
+++ test/cctest/test-parsing.cc
@@ -1048,8 +1048,9 @@
 i::Handle<i::String> FormatMessage(i::ScriptDataImpl* data) {
   i::Isolate* isolate = i::Isolate::Current();
   i::Factory* factory = isolate->factory();
+  const char* message = data->BuildMessage();
   i::Handle<i::String> format = v8::Utils::OpenHandle(
-                                    *v8::String::New(data->BuildMessage()));
+                                    *v8::String::New(message));
   i::Vector<const char*> args = data->BuildArgs();
   i::Handle<i::JSArray> args_array = factory->NewJSArray(args.length());
   for (int i = 0; i < args.length(); i++) {
@@ -1068,6 +1069,11 @@
       i::Execution::Call(format_fun, builtins, 2, arg_handles, &has_exception);
   CHECK(!has_exception);
   CHECK(result->IsString());
+  for (int i = 0; i < args.length(); i++) {
+    i::DeleteArray(args[i]);
+  }
+  i::DeleteArray(args.start());
+  i::DeleteArray(message);
   return i::Handle<i::String>::cast(result);
 }

@@ -1279,7 +1285,7 @@
             + kSuffixLen + i::StrLength("label: for (;;) {  }");

         // Plug the source code pieces together.
-        i::Vector<char> program = i::Vector<char>::New(kProgramSize + 1);
+        i::ScopedVector<char> program(kProgramSize + 1);
         int length = i::OS::SNPrintF(program,
             "label: for (;;) { %s%s%s%s }",
             context_data[i][0],