Ejemplo n.º 1
0
    void TimersBase<ClockPolicy, CommsPolicy>::Report(ctemplate::TemplateDictionary& dictionary)
    {
      dictionary.SetIntValue("THREADS", CommsPolicy::GetProcessorCount());

      for (unsigned int ii = 0; ii < numberOfTimers; ii++)
      {
        ctemplate::TemplateDictionary *timer = dictionary.AddSectionDictionary("TIMER");
        timer->SetValue("NAME", timerNames[ii]);
        timer->SetFormattedValue("LOCAL", "%.3g", timers[ii].Get());
        timer->SetFormattedValue("MIN", "%.3g", Mins()[ii]);
        timer->SetFormattedValue("MEAN", "%.3g", Means()[ii]);
        timer->SetFormattedValue("MAX", "%.3g", Maxes()[ii]);
      }
    }
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: Shumen/cgi
void fill_amortization_dictionary(
  ctemplate::TemplateDictionary& dict, Request& req)
{
  dict.SetValue("LoanAmt", req.post.count("LoanAmt")
      ? "$250,000" : req.post["LoanAmt"]);
  dict.SetIntValue("YearlyIntRate", req.post.pick("YearlyIntRate", 6.000));

  boost::array<std::string, 8> year_opts
    = {{ "5", "7", "10", "20", "30", "40", "50" }};
    
  BOOST_FOREACH(std::string& year, year_opts)
  {
    dict.SetValueAndShowSection("TermYrs", year, "SELECT_TERM_YEARS");
  }
Ejemplo n.º 3
0
static bool atpArrayToCtemplateDicts(ctemplate::TemplateDictionary &p_tplDict, ATP_Array *p_atpArray, const std::string &p_key)
{
    unsigned int i;
    DBG("array %p has %u entries\n", *p_atpArray, ATP_arrayLength(p_atpArray));
    for (i = 0; i < ATP_arrayLength(p_atpArray); ++i)
    {
        DBG("reading from array %p entry (type %s) %u\n", *p_atpArray, ATP_valueTypeToString(ATP_arrayGetType(p_atpArray, i)), i);
        switch (ATP_arrayGetType(p_atpArray, i))
        {
            case e_ATP_ValueType_dict:
                {
                    ATP_Dictionary *l_value = NULL;
                    ctemplate::TemplateDictionary *l_subDict = p_tplDict.AddSectionDictionary(p_key);

                    ATP_arrayGetDict(p_atpArray, i, &l_value);
                    if (!atpDictToCtemplateDict(*l_subDict, l_value))
                    {
                        return false;
                    }
                    DBG("processed dictionary %p\n", *l_value);
                }
                break;
            default:
                // NOTE: ignore anything that is not a dictionary
                DBG(PROCNAME ": A non-dictionary array entry was ignored\n");
                break;
        }
    }

    return 1;
}
 void IncompressibilityChecker<BroadcastPolicy>::Report(ctemplate::TemplateDictionary& dictionary)
 {
   if (AreDensitiesAvailable() && !IsDensityDiffWithinRange())
   {
     ctemplate::TemplateDictionary *incomp = dictionary.AddSectionDictionary("DENSITIES");
     incomp->SetFormattedValue("ALLOWED", "%.1f%%", GetMaxRelativeDensityDifferenceAllowed() * 100);
     incomp->SetFormattedValue("ACTUAL", "%.1f%%", GetMaxRelativeDensityDifference() * 100);
   }
 }
Ejemplo n.º 5
0
static bool atpDictToCtemplateDict(ctemplate::TemplateDictionary &p_tplDict, ATP_Dictionary *p_atpDict)
{
    ATP_DictionaryIterator it;
    DBG("dictionary %p has %u entries\n", *p_atpDict, ATP_dictionaryCount(p_atpDict));
    for (it = ATP_dictionaryBegin(p_atpDict); ATP_dictionaryHasNext(it); it = ATP_dictionaryNext(it))
    {
        std::string l_key = ATP_dictionaryGetKey(it);

        DBG("reading from %p entry (type %s) '%s'\n", *p_atpDict, ATP_valueTypeToString(ATP_dictionaryGetType(it)), l_key.c_str());
        switch (ATP_dictionaryGetType(it))
        {
            case e_ATP_ValueType_string:
                {
                    const char *l_value = NULL;
                    ATP_dictionaryItGetString(it, &l_value);
                    p_tplDict.SetValue(l_key, l_value);
                }
                break;
            case e_ATP_ValueType_uint:
                {
                    unsigned long long l_value = 0;
                    ATP_dictionaryItGetUint(it, &l_value);
                    p_tplDict.SetValue(l_key, toString(l_value));
                }
                break;
            case e_ATP_ValueType_int:
                {
                    signed long long l_value = 0;
                    ATP_dictionaryItGetInt(it, &l_value);
                    p_tplDict.SetValue(l_key, toString(l_value));
                }
                break;
            case e_ATP_ValueType_double:
                {
                    double l_value = 0.0;
                    ATP_dictionaryItGetDouble(it, &l_value);
                    p_tplDict.SetValue(l_key, toString(l_value));
                }
                break;
            case e_ATP_ValueType_bool:
                {
                    int l_value = 0;
                    ATP_dictionaryItGetBool(it, &l_value);
                    p_tplDict.SetValue(l_key, (l_value ? "true" : "false"));
                }
                break;
            case e_ATP_ValueType_dict:
                {
                    ATP_Dictionary *l_value = NULL;
                    ctemplate::TemplateDictionary *l_subDict = p_tplDict.AddSectionDictionary(l_key);

                    ATP_dictionaryItGetDict(it, &l_value);
                    if (!atpDictToCtemplateDict(*l_subDict, l_value))
                    {
                        return false;
                    }
                    DBG("processed dictionary %p\n", *l_value);
                }
                break;
            case e_ATP_ValueType_array:
                {
                    ATP_Array *l_value = NULL;
                    ATP_dictionaryItGetArray(it, &l_value);
                    if (!atpArrayToCtemplateDicts(p_tplDict, l_value, l_key))
                    {
                        return false;
                    }
                    DBG("processed array %p\n", *l_value);
                }
                break;
            default:
                break;
        }
    }

    return true;
}