本文整理汇总了C++中Treelog::error方法的典型用法代码示例。如果您正苦于以下问题:C++ Treelog::error方法的具体用法?C++ Treelog::error怎么用?C++ Treelog::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Treelog
的用法示例。
在下文中一共展示了Treelog::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
bool check (Treelog& msg)
{
if (!lex.good ())
return false;
bool ok = true;
if (c_x_pos < 0)
{
msg.error ("Position X: tag missing");
ok = false;
}
if (c_z_min < 0)
{
msg.error ("Position Z minimum: tag missing");
ok = false;
}
if (c_z_max < 0)
{
msg.error ("Position Z maximum: tag missing");
ok = false;
}
if (c_density < 0)
{
msg.error ("Root lenght density: tag missing");
ok = false;
}
return ok;
}
示例2: valid
bool valid (const PLF& plf, Treelog& msg) const
{
if (plf.size () < 1)
{
msg.error ("PLF must be non-empty");
return false;
}
const size_t first = 0;
const size_t last = plf.size () - 1;
const double first_x = plf.x (first);
const double first_y = plf.y (first);
const double last_x = plf.x (last);
const double last_y = plf.y (last);
if (first_x < 1 || last_x > 366)
{
msg.error ("Julian day must be between 1 and 366");
return false;
}
if (!approximate (first_y, last_y))
{
std::ostringstream tmp;
tmp << "First (" << first_y << ") and last (" << last_y
<< ") value must be identical";
msg.error (tmp.str ());
return false;
}
return true;
}
示例3: verify
bool verify (const Metalib&, const Frame& frame, const symbol key,
Treelog& msg) const
{
daisy_assert (key == "SOM_fractions");
daisy_assert (frame.check (key));
daisy_assert (frame.lookup (key) == Attribute::Number);
daisy_assert (frame.type_size (key) == Attribute::Variable);
std::vector<double> fractions = frame.number_sequence ("SOM_fractions");
bool has_negative = false;
double sum = 0.0;
for (unsigned int i = 0; i < fractions.size (); i++)
{
if (fractions[i] < 0)
has_negative = true;
else
sum += fractions[i];
}
if (!has_negative && !approximate (sum, 1.0))
{
msg.error ("sum must be 1.0");
return false;
}
if (sum > 1.0 && !approximate (sum, 1.0))
{
msg.error ("sum must be at most 1.0");
return false;
}
return true;
};
示例4: initialize
void initialize (const Texture& texture,
double rho_b, const bool top_soil, const double CEC,
const double center_z, Treelog& msg)
{
TREELOG_MODEL (msg);
std::ostringstream tmp;
// Find Theta_sat.
if (Theta_sat < 0.0)
{
if (rho_b < 0.0)
{
msg.error ("You must specify either dry bulk density or porosity");
rho_b = 1.5;
tmp << "Forcing rho_b = " << rho_b << " g/cm^3\n";
}
Theta_sat = 1.0 - rho_b / texture.rho_soil_particles ();
tmp << "(Theta_sat " << Theta_sat << " [])\n";
daisy_assert (Theta_sat < 1.0);
}
if (Theta_sat <= Theta_fc)
{
msg.error ("Field capacity must be below saturation point");
Theta_sat = (1.0 + 4.0 * Theta_fc) / 5.0;
tmp << "Forcing Theta_sat = " << Theta_sat << " []\n";
}
// Find Theta_wp.
if (Theta_wp < 0.0)
{
const double clay_lim // USDA Clay
= texture.fraction_of_minerals_smaller_than ( 2.0 /* [um] */);
const double silt_lim // USDA Silt
= texture.fraction_of_minerals_smaller_than (50.0 /* [um] */);
daisy_assert (clay_lim >= 0.0);
daisy_assert (silt_lim >= clay_lim);
daisy_assert (silt_lim <= 1.0);
const double mineral = texture.mineral ();
const double clay = mineral * clay_lim * 100 /* [%] */;
const double silt = mineral * (silt_lim - clay_lim) * 100 /* [%] */;
const double humus = texture.humus * 100 /* [%] */;
// Madsen and Platou (1983).
Theta_wp = 0.758 * humus + 0.520 * clay + 0.075 * silt + 0.42;
Theta_wp /= 100.0; // [%] -> []
}
b = find_b (Theta_wp, Theta_fc);
h_b = find_h_b (Theta_wp, Theta_fc, Theta_sat, b);
tmp << "(b " << b << " [])\n"
<< "(h_b " << h_b << " [cm])";
msg.debug (tmp.str ());
// Must be called last (K_init depends on the other parameters).
Hydraulic::initialize (texture, rho_b, top_soil, CEC, center_z, msg);
}
示例5: propagate
static void propagate (Treelog& msg, int nest, const std::string& text)
{
switch (nest)
{
case is_unknown:
msg.entry (text);
break;
case is_debug:
msg.debug (text);
break;
case is_plain:
msg.message (text);
break;
case is_warning:
msg.warning (text);
break;
case is_error:
msg.error (text);
break;
case is_bug:
msg.bug (text);
break;
case is_close:
msg.close ();
break;
case is_touch:
msg.touch ();
break;
case is_flush:
msg.flush ();
break;
default:
msg.open (text);
}
}
示例6:
bool
VCheck::MultiSize::verify (const Metalib&, const Frame& frame,
const symbol key, Treelog& msg) const
{
daisy_assert (frame.check (key));
daisy_assert (!frame.is_log (key));
daisy_assert (frame.type_size (key) != Attribute::Singleton);
if (sizes.find (frame.value_size (key)) != sizes.end ())
return true;
std::ostringstream tmp;
tmp << "'" << key << "' has " << frame.value_size (key)
<< " elements, expected one of { ";
bool first = true;
for (std::set<size_t>::const_iterator i = sizes.begin ();
i != sizes.end ();
i++)
{
if (first)
first = false;
else
tmp << ", ";
tmp << *i;
}
tmp << " } elements";
msg.error (tmp.str ());
return false;
}
示例7: nest
bool
ChemistryMulti::check (const Scope& scope, const Geometry& geo,
const Soil& soil, const SoilWater& soil_water,
const SoilHeat& soil_heat, const Chemistry& chemistry,
Treelog& msg) const
{
bool ok = true;
for (size_t c = 0; c < combine.size (); c++)
{
Treelog::Open nest (msg, "Chemistry: '" + combine[c]->objid + "'");
if (!combine[c]->check (scope, geo, soil, soil_water, soil_heat,
chemistry, msg))
ok = false;
}
// Check for duplicate chemicals.
std::map<symbol, size_t> found;
for (size_t i = 0; i < chemicals.size (); i++)
{
const symbol type = chemicals[i]->objid;
std::map<symbol, size_t>::const_iterator f = found.find (type);
if (f != found.end ())
{
std::ostringstream tmp;
tmp << "Chemical '" << type << "' definded in multiple chemistries:";
for (size_t j = 0; j < combine.size (); j++)
if (combine[j]->know (type))
tmp << " '" << combine[j]->objid << "'";
msg.error (tmp.str ());
ok = false;
}
found[type] = i;
}
return ok;
}
示例8:
bool
Frame::Implementation::check (const Metalib& metalib, const Frame& frame,
Treelog& msg) const
{
bool ok = true;
const FrameModel* model = dynamic_cast<const FrameModel*> (&frame);
if (model && !model->buildable ())
{
msg.error ("'" + frame.type_name ()
+ "' is a base model, for internal use only");
ok = false;
}
for (type_map::const_iterator i = types.begin ();
i != types.end ();
i++)
{
const symbol key = (*i).first;
const Type& type = *(*i).second;
if (!frame.is_reference (key)
&& !check (metalib, frame, type, key, msg))
ok = false;
}
if (!ok)
return false;
if (!frame.has_references ())
for (size_t j = 0; j < checker.size (); j++)
if (!checker[j] (metalib, frame, msg))
return false;
return true;
}
示例9: switch
bool
VolumeBox::limit (const Volume& other, Treelog& msg)
{
if (const VolumeBox* limit = dynamic_cast<const VolumeBox*> (&other))
{
for (size_t i = 0; i < bounds_size; i++)
{
Bound& bound = *(this->*(bounds[i].bound));
if (bound.type () == Bound::none)
{
const Bound& lim = *(limit->*(bounds[i].bound));
switch (lim.type ())
{
case Bound::none:
/* do nothing */;
break;
case Bound::full:
bound.set_full ();
break;
case Bound::finite:
bound.set_finite (lim.value ());
break;
}
}
}
return true;
}
msg.error ("Don't know how to limit a '" + objid
+ "' to a '" + other.objid + "'");
return false;
}
示例10:
bool
ReactionNitrification::check (const Units&, const Geometry&,
const Soil&, const SoilWater&, const SoilHeat&,
const Chemistry& chemistry, Treelog& msg) const
{
bool ok = true;
if (!chemistry.know (Chemical::NO3 ()))
{
msg.error ("Nitrification requires NO3 to be tracked");
ok = false;
}
if (!chemistry.know (Chemical::NH4 ()))
{
msg.error ("Nitrification requires NH4 to be tracked");
ok = false;
}
return ok;
}
示例11: valid
bool valid (double last, double next, Treelog& msg) const
{
if (last > next)
return true;
std::ostringstream tmp;
tmp << last << " <= " << next << ", must be decreasing";
msg.error (tmp.str ());
return false;
}
示例12: has_attribute
bool has_attribute (const symbol name, Treelog& msg) const
{
bool missing = false;
for (size_t i = 0; i < layers.size (); i++)
if (!layers[i]->horizon->has_attribute (name))
{
msg.error ("Required attribute '"
+ name + "' is missing from the soil horizon '"
+ layers[i]->horizon->objid + "'");
missing = true;
}
for (size_t i = 0; i < zones.size (); i++)
if (!zones[i]->horizon->has_attribute (name))
{
msg.error ("Required attribute '"
+ name + "' is missing from the soil zone '"
+ zones[i]->horizon->objid + "'");
missing = true;
}
return !missing;
}
示例13: plf
bool
VCheck::FixedPoint::valid (const PLF& plf, Treelog& msg) const
{
if (approximate (plf (fixed_x), fixed_y))
return true;
std::ostringstream tmp;
tmp << "Value at " << fixed_x << " should be " << fixed_y
<< " but is << " << plf (fixed_x);
msg.error (tmp.str ());
return false;
}
示例14:
bool
SoilWater::check (const size_t n, Treelog& msg) const
{
bool ok = true;
if (Theta_.size () != n)
{
std::ostringstream tmp;
tmp << "You have " << n
<< " intervals but " << Theta_.size () << " Theta values";
msg.error (tmp.str ());
ok = false;
}
if (h_.size () != n)
{
std::ostringstream tmp;
tmp << "You have " << n
<< " intervals but " << h_.size () << " h values";
msg.error (tmp.str ());
ok = false;
}
if (X_ice_.size () != n)
{
std::ostringstream tmp;
tmp << "You have " << n
<< " intervals but " << X_ice_.size () << " X_ice values";
msg.error (tmp.str ());
ok = false;
}
if (X_ice_buffer_.size () != n)
{
std::ostringstream tmp;
tmp << "You have " << n
<< " intervals but " << X_ice_buffer_.size ()
<< " X_ice_buffer values";
msg.error (tmp.str ());
ok = false;
}
return ok;
}
示例15: check
// Create.
bool check (const Units&, const Geometry&,
const Soil&, const SoilWater&, const SoilHeat&,
const Chemistry& chemistry, Treelog& msg) const
{
bool ok = true;
if (!chemistry.know (immobile))
{
msg.error ("'" + immobile + "' not traced");
ok = false;
}
if (!chemistry.know (bound) && bound != Attribute::None ())
{
msg.error ("'" + bound + "' not traced");
ok = false;
}
if (!chemistry.know (colloid))
{
msg.error ("'" + colloid + "' not traced");
ok = false;
}
return ok;
}