本文整理汇总了C++中DBG_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ DBG_ASSERT函数的具体用法?C++ DBG_ASSERT怎么用?C++ DBG_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DBG_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBG_START_METH
bool PDSearchDirCalculator::ComputeSearchDirection()
{
DBG_START_METH("PDSearchDirCalculator::ComputeSearchDirection",
dbg_verbosity);
bool improve_solution = false;
if (IpData().HaveDeltas()) {
improve_solution = true;
}
bool retval;
if (improve_solution && fast_step_computation_) {
retval = true;
}
else {
SmartPtr<IteratesVector> rhs = IpData().curr()->MakeNewContainer();
rhs->Set_x(*IpCq().curr_grad_lag_with_damping_x());
rhs->Set_s(*IpCq().curr_grad_lag_with_damping_s());
rhs->Set_y_c(*IpCq().curr_c());
rhs->Set_y_d(*IpCq().curr_d_minus_s());
Index nbounds = IpNLP().x_L()->Dim()+ IpNLP().x_U()->Dim() +
IpNLP().d_L()->Dim()+ IpNLP().d_U()->Dim();
if (nbounds>0 && mehrotra_algorithm_) {
// set up the right hand side a la Mehrotra
DBG_ASSERT(IpData().HaveAffineDeltas());
DBG_ASSERT(!IpData().HaveDeltas());
const SmartPtr<const IteratesVector> delta_aff = IpData().delta_aff();
SmartPtr<Vector> tmpvec = delta_aff->z_L()->MakeNew();
IpNLP().Px_L()->TransMultVector(1., *delta_aff->x(), 0., *tmpvec);
tmpvec->ElementWiseMultiply(*delta_aff->z_L());
tmpvec->Axpy(1., *IpCq().curr_relaxed_compl_x_L());
rhs->Set_z_L(*tmpvec);
tmpvec = delta_aff->z_U()->MakeNew();
IpNLP().Px_U()->TransMultVector(-1., *delta_aff->x(), 0., *tmpvec);
tmpvec->ElementWiseMultiply(*delta_aff->z_U());
tmpvec->Axpy(1., *IpCq().curr_relaxed_compl_x_U());
rhs->Set_z_U(*tmpvec);
tmpvec = delta_aff->v_L()->MakeNew();
IpNLP().Pd_L()->TransMultVector(1., *delta_aff->s(), 0., *tmpvec);
tmpvec->ElementWiseMultiply(*delta_aff->v_L());
tmpvec->Axpy(1., *IpCq().curr_relaxed_compl_s_L());
rhs->Set_v_L(*tmpvec);
tmpvec = delta_aff->v_U()->MakeNew();
IpNLP().Pd_U()->TransMultVector(-1., *delta_aff->s(), 0., *tmpvec);
tmpvec->ElementWiseMultiply(*delta_aff->v_U());
tmpvec->Axpy(1., *IpCq().curr_relaxed_compl_s_U());
rhs->Set_v_U(*tmpvec);
}
else {
rhs->Set_z_L(*IpCq().curr_relaxed_compl_x_L());
rhs->Set_z_U(*IpCq().curr_relaxed_compl_x_U());
rhs->Set_v_L(*IpCq().curr_relaxed_compl_s_L());
rhs->Set_v_U(*IpCq().curr_relaxed_compl_s_U());
}
DBG_PRINT_VECTOR(2, "rhs", *rhs);
// Get space for the search direction
SmartPtr<IteratesVector> delta =
IpData().curr()->MakeNewIteratesVector(true);
if (improve_solution) {
// We can probably avoid copying and scaling...
delta->AddOneVector(-1., *IpData().delta(), 0.);
}
bool& allow_inexact = fast_step_computation_;
retval = pd_solver_->Solve(-1.0, 0.0, *rhs, *delta, allow_inexact,
improve_solution);
if (retval) {
// Store the search directions in the IpData object
IpData().set_delta(delta);
}
}
return retval;
}
示例2: DBG_ASSERT
bool IpoptData::InitializeDataStructures(IpoptNLP& ip_nlp,
bool want_x,
bool want_y_c,
bool want_y_d,
bool want_z_L,
bool want_z_U)
{
DBG_ASSERT(initialize_called_);
/*
* Allocate space for all the required linear algebra
* structures
*/
SmartPtr<Vector> new_x;
SmartPtr<Vector> new_s;
SmartPtr<Vector> new_y_c;
SmartPtr<Vector> new_y_d;
SmartPtr<Vector> new_z_L;
SmartPtr<Vector> new_z_U;
SmartPtr<Vector> new_v_L;
SmartPtr<Vector> new_v_U;
// Get the required linear algebra structures from the model
bool retValue
= ip_nlp.InitializeStructures(new_x, want_x,
new_y_c, want_y_c,
new_y_d, want_y_d,
new_z_L, want_z_L,
new_z_U, want_z_U,
new_v_L, new_v_U);
if (!retValue) {
return false;
}
new_s = new_y_d->MakeNew(); // same dimension as d
iterates_space_ = new IteratesVectorSpace(*(new_x->OwnerSpace()), *(new_s->OwnerSpace()),
*(new_y_c->OwnerSpace()), *(new_y_d->OwnerSpace()),
*(new_z_L->OwnerSpace()), *(new_z_U->OwnerSpace()),
*(new_v_L->OwnerSpace()), *(new_v_U->OwnerSpace())
);
curr_ = iterates_space_->MakeNewIteratesVector(*new_x,
*new_s,
*new_y_c,
*new_y_d,
*new_z_L,
*new_z_U,
*new_v_L,
*new_v_U);
#if COIN_IPOPT_CHECKLEVEL > 0
debug_curr_tag_ = curr_->GetTag();
debug_curr_tag_sum_ = curr_->GetTagSum();
debug_trial_tag_ = 0;
debug_trial_tag_sum_ = 0;
debug_delta_tag_ = 0;
debug_delta_tag_sum_ = 0;
debug_delta_aff_tag_ = 0;
debug_delta_aff_tag_sum_ = 0;
#endif
trial_ = NULL;
// Set the pointers for storing steps to NULL
delta_ = NULL;
delta_aff_ = NULL;
have_prototypes_ = true;
have_deltas_ = false;
have_affine_deltas_ = false;
return cgpen_data_->InitializeDataStructures();
}
示例3: send
/*************** send function - tcp_full only ***********************/
size_t send(const void *data_ptr, size_t data_len) throw()
{ DBG_ASSERT(tcp_full); return tcp_full->send(data_ptr, data_len); }
示例4: LogError
/*! \brief Log an error entry in the system log
Log an error entry in the system log.
\param Fdo
Pointer to a DEVICE_OBJECT structure.
This is the device object for the target device,
previously created by the driver's AddDevice routine.
\param ErrorCode
The NTSTATUS code which should be reported on behalf of
this error log entry
\param String1
Pointer to the 1st (WCHAR) string which has to be included
into the error log entry. This can be NULL if no string
is to be inserted.
\param String2
Pointer to the 2nd (WCHAR) string which has to be included
into the error log entry. This can be NULL if no string
is to be inserted.
*/
VOID
LogError(IN PDEVICE_OBJECT Fdo,
IN NTSTATUS ErrorCode,
const WCHAR *String1,
const WCHAR *String2)
{
USHORT stringSize;
USHORT stringOffset;
USHORT stringSize1;
USHORT stringSize2;
USHORT size;
USHORT numberOfStrings;
FUNC_ENTER();
// IoAllocateErrorLogEntry() and IoWriteErrorLogEntry() require this
DBG_IRQL( <= DISPATCH_LEVEL);
// calculate the size of the strings
numberOfStrings = 0;
// Check if there is a string 1, and calculate its size
// (including the trailing zero)
stringSize1 = String1 ? (++numberOfStrings, sizeof(WCHAR) * (wcslen(String1) + 1)) : 0;
// Check if there is a string 2, and calculate its size
// (including the trailing zero)
stringSize2 = String2 ? (++numberOfStrings, sizeof(WCHAR) * (wcslen(String2) + 1)) : 0;
// Add the sizes of both strings
// This is the size of what has to be added to the error log entry
stringSize = stringSize1 + stringSize2;
// Offset where the string(s) will be written into the error log entry
stringOffset = sizeof(IO_ERROR_LOG_PACKET);
// The complete size of the event log entry
size = stringOffset + stringSize;
// Make sure we don't need more space than needed.
// For debugging purposes, have an DBG_ASSERT(). Anyway,
// in the wild, don't do anything if the size is too big.
// Remember: Not being able to write a log is not an error!
/*! \todo Would it make sense to short the strings if the
* error log entry would be too big?
*/
DBG_ASSERT(size <= ERROR_LOG_MAXIMUM_SIZE);
if (size <= ERROR_LOG_MAXIMUM_SIZE)
{
PIO_ERROR_LOG_PACKET pentry;
// allocate the entry for the error log
DBG_IRQL( <= DISPATCH_LEVEL);
pentry = IoAllocateErrorLogEntry(Fdo, (UCHAR) size);
DBG_ASSERT(pentry);
if (pentry) {
// clear the complete entry (to be sure)
RtlZeroMemory(pentry, sizeof(*pentry));
// Write the relevant entries
pentry->NumberOfStrings = numberOfStrings;
pentry->StringOffset = stringOffset;
//.........这里部分代码省略.........
示例5: fb_ExecEx
/*:::::*/
FBCALL int fb_ExecEx ( FBSTRING *program, FBSTRING *args, int do_fork )
{
char buffer[MAX_PATH+1], *application, *arguments, **argv, *p;
int i, argc = 0, res = -1, status, len_program, len_arguments;
pid_t pid;
if( (program == NULL) || (program->data == NULL) )
{
fb_hStrDelTemp( args );
fb_hStrDelTemp( program );
return -1;
}
application = fb_hGetShortPath( program->data, buffer, MAX_PATH );
DBG_ASSERT( application!=NULL );
if( application==program->data )
{
len_program = FB_STRSIZE( program );
application = buffer;
FB_MEMCPY(application, program->data, len_program );
application[len_program] = 0;
}
fb_hConvertPath( application );
if( args==NULL )
{
arguments = "";
}
else
{
len_arguments = FB_STRSIZE( args );
arguments = alloca( len_arguments + 1 );
DBG_ASSERT( arguments!=NULL );
arguments[len_arguments] = 0;
if( len_arguments )
argc = fb_hParseArgs( arguments, args->data, len_arguments );
}
FB_STRLOCK();
fb_hStrDelTemp_NoLock( args );
fb_hStrDelTemp_NoLock( program );
FB_STRUNLOCK();
if( argc == -1 )
return -1;
argc++; /* add 1 for program name */
argv = alloca( sizeof(char*) * (argc + 1 ));
DBG_ASSERT( argv!=NULL );
argv[0] = application;
/* scan the processed args and set pointers */
p = arguments;
for( i=1 ; i<argc; i++) {
argv[i] = p; /* set pointer to current argument */
while( *p++ ); /* skip to 1 char past next null char */
}
argv[argc] = NULL;
/* Launch */
fb_hExitConsole();
if( do_fork ) {
pid = fork();
if( pid != -1 ) {
if (pid == 0) {
/* execvp() only returns if it failed */
execvp( application, argv );
/* HACK: execvp() failed, this must be communiated to the parent process *somehow*,
so fb_ExecEx() can return -1 there */
exit( 255 );
/* FIXME: won't be able to tell the difference if the exec'ed program returned 255.
Maybe a pipe could be used instead of the 255 exit code? Unless that's too slow/has side-effects */
} else if( (waitpid(pid, &status, 0) > 0) && WIFEXITED(status) ) {
res = WEXITSTATUS(status);
if( res == 255 ) {
/* See the HACK above */
res = -1;
}
}
}
} else {
res = execvp( application, argv );
}
fb_hInitConsole();
return res;
}
示例6: GetValue
/** Method for retrieving the value of an option. Calling this
* method will increase the counter by one. */
std::string GetValue() const
{
DBG_ASSERT(initialized_);
counter_++;
return value_;
}
示例7: Counter
/** Method for accessing current value of the request counter */
Index Counter() const
{
DBG_ASSERT(initialized_);
return counter_;
}
示例8: DBG_ASSERT
Index CompoundSymMatrixSpace::GetBlockDim(Index irow_jcol) const
{
DBG_ASSERT(dimensions_set_ && "Cannot get block dimensions before all dimensions are set.");
DBG_ASSERT(irow_jcol < ncomp_spaces_);
return block_dim_[irow_jcol];
}
示例9: MatricesValid
void CompoundSymMatrix::MultVectorImpl(Number alpha, const Vector &x,
Number beta, Vector &y) const
{
if (!matrices_valid_) {
matrices_valid_ = MatricesValid();
}
DBG_ASSERT(matrices_valid_);
// The vectors are assumed to be compound Vectors as well
const CompoundVector* comp_x = static_cast<const CompoundVector*>(&x);
DBG_ASSERT(dynamic_cast<const CompoundVector*>(&x));
CompoundVector* comp_y = static_cast<CompoundVector*>(&y);
DBG_ASSERT(dynamic_cast<CompoundVector*>(&y));
// A few sanity checks
if (comp_x) {
DBG_ASSERT(NComps_Dim()==comp_x->NComps());
}
else {
DBG_ASSERT(NComps_Dim() == 1);
}
if (comp_y) {
DBG_ASSERT(NComps_Dim()==comp_y->NComps());
}
else {
DBG_ASSERT(NComps_Dim() == 1);
}
// Take care of the y part of the addition
if ( beta!=0.0 ) {
y.Scal(beta);
}
else {
y.Set(0.0); // In case y hasn't been initialized yet
}
for (Index irow=0; irow<NComps_Dim(); irow++) {
SmartPtr<Vector> y_i;
if (comp_y) {
y_i = comp_y->GetCompNonConst(irow);
}
else {
y_i = &y;
}
DBG_ASSERT(IsValid(y_i));
for (Index jcol=0; jcol<=irow; jcol++) {
SmartPtr<const Vector> x_j;
if (comp_x) {
x_j = comp_x->GetComp(irow);
}
else {
x_j = &x;
}
DBG_ASSERT(IsValid(x_j));
if (ConstComp(irow,jcol)) {
ConstComp(irow,jcol)->MultVector(alpha, *comp_x->GetComp(jcol),
1., *comp_y->GetCompNonConst(irow));
}
}
for (Index jcol = irow+1; jcol < NComps_Dim(); jcol++) {
if (ConstComp(jcol,irow)) {
ConstComp(jcol,irow)->TransMultVector(alpha, *comp_x->GetComp(jcol),
1., *comp_y->GetCompNonConst(irow));
}
}
}
}
示例10: DBG_ASSERT
// Reference this object by increasing the reference count
void GTObject::AddReference(void)
{
DBG_ASSERT(m_nReferenceCount > 0);
m_nReferenceCount++;
}
示例11: _TreeImpMetadataBase
explicit
_TreeImpMetadataBase(PyObject * seq, PyObject * metadata, const LT & lt) :
BaseT(seq, MetadataT(metadata), lt)
{
DBG_ASSERT(seq != NULL);
}
示例12: while
bool OptionsList::ReadFromStream(const Journalist& jnlst,
std::istream& is)
{
jnlst.Printf(J_DETAILED, J_MAIN, "Start reading options from stream.\n");
while (true) {
std::string tag;
std::string value;
if (!readnexttoken(is, tag)) {
// That's it - end of file reached.
jnlst.Printf(J_DETAILED, J_MAIN,
"Finished reading options from file.\n");
return true;
}
if (!readnexttoken(is, value)) {
// Can't read value for a given tag
jnlst.Printf(J_ERROR, J_MAIN,
"Error reading value for tag %s from file.\n",
tag.c_str());
return false;
}
// Now add the value for the options list
jnlst.Printf(J_DETAILED, J_MAIN,
"Adding option \"%s\" with value \"%s\" to OptionsList.\n",
tag.c_str(), value.c_str());
if (IsValid(reg_options_)) {
SmartPtr<const RegisteredOption> option = reg_options_->GetOption(tag);
if (IsNull(option)) {
std::string msg = "Read Option: ";
msg += tag;
msg += ". It is not a valid option. Check the list of available options.";
THROW_EXCEPTION(OPTION_INVALID, msg);
}
if (option->Type() == OT_String) {
bool result = SetStringValue(tag, value, false);
ASSERT_EXCEPTION(result, OPTION_INVALID,
"Error setting string value read from option file.");
}
else if (option->Type() == OT_Number) {
char* p_end;
Number retval = strtod(value.c_str(), &p_end);
if (*p_end!='\0' && !isspace(*p_end)) {
std::string msg = "Option \"" + tag +
"\": Double value expected, but non-numeric option value \"" +
value + "\" found.\n";
THROW_EXCEPTION(OPTION_INVALID, msg);
}
bool result = SetNumericValue(tag, retval, false);
ASSERT_EXCEPTION(result, OPTION_INVALID,
"Error setting numeric value read from file.");
}
else if (option->Type() == OT_Integer) {
char* p_end;
Index retval = strtol(value.c_str(), &p_end, 10);
if (*p_end!='\0' && !isspace(*p_end)) {
std::string msg = "Option \"" + tag +
"\": Integer value expected, but non-integer option value \"" +
value + "\" found.\n";
if (IsValid(jnlst_)) {
option->OutputDescription(*jnlst_);
}
THROW_EXCEPTION(OPTION_INVALID, msg);
}
bool result = SetIntegerValue(tag, retval, false);
ASSERT_EXCEPTION(result, OPTION_INVALID,
"Error setting integer value read from option file.");
}
else {
DBG_ASSERT(false && "Option Type: Unknown");
}
}
else {
bool result = SetStringValue(tag, value, false);
ASSERT_EXCEPTION(result, OPTION_INVALID,
"Error setting value read from option file.");
}
}
}
示例13: NLP_scaling
/** Returns the scaling strategy object */
SmartPtr<NLPScalingObject> NLP_scaling() const
{
DBG_ASSERT(IsValid(nlp_scaling_));
return nlp_scaling_;
}
示例14: onet_vdev_in
/**
* callback to received data from the vdev
* - if a established tunnel exist, send the packet to it
* - if a tunnel is currently in establishment, set the triggering packet
* - if no tunnel exist, start the establishement on one
*/
static void onet_vdev_in( void *userptr, int ethertype, char *pkt, int pkt_len )
{
struct iphdr *iph = (struct iphdr *)pkt;
onet_t *onet = onet_main;
onet_tunnel_t *tunnel;
ip_addr_t dst_iaddr;
DBG("enter ethertype=0x%x\n", ethertype );
// handle only ipv4 for now
EXP_ASSERT( ethertype == ETHERTYPE_IP );
// sanity check
// TODO put the basic check of the ipv4 packet in a function
if( pkt_len < sizeof(*iph) ){
LOG(0,"received bogus packet of %d-byte. not even big enought for an ipv4 header\n", pkt_len );
return;
}
if( pkt_len < iph->ihl*4 ){
LOG(0,"received bogus packet of %d-byte with ipv4_hd->ihl=%d\n", pkt_len, iph->ihl*4 );
return;
}
// get the destination ip address from the packet
ip_addr_v4_set( &dst_iaddr, ntohl(iph->daddr) );
// find a existing tunnel if there is any
tunnel = onet_tunnel_from_remote_iaddr( &dst_iaddr );
// if there is a tunnel and the connection is already established, send it thru it
if( tunnel && tunnel->stun ){
DBG("there is already a establish link for this packet \n");
// TMP: just to test the limitor
if( rate_limit_exceeded( tunnel->thput_limit) ){
// LOGM_ERR("packet discarded due to rate limiter\n");
return;
}
// update the pkt_rate and throughput
rate_estim_add( tunnel->pkt_rate, 1 );
rate_estim_add( tunnel->throughput, pkt_len );
// send the packet
stun_out_data( tunnel->stun, ethertype, pkt, pkt_len );
return;
}
// if the ipaddr is in the dst_iaddr_negcache, return
if( dst_iaddr_negcache_is_present( onet->dst_iaddr_negcache, &dst_iaddr) ){
// return an ICMP if the ip record is in the dst_iaddr_negcache
// - apply the concept of not replying a icmp immediatly to let
// the time to resolve the address
// - similar to the time to solve the hw address with ARP
// - as in rfc2461.7.2.2, ICMP must be replied after 3sec
// - it is ONET_DELAY_B4_ICMP
// TODO the timer aspect isnt well respected now
// - itor has its own timer see bug 359
// - onet_ns_req_dst_iaddr_* honor it tho
raw_icmp_reply_send( ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0, pkt, pkt_len );
return;
}
// if there no record for this dst_iaddr in the local database, discard the packet
if( onet_ns_req_dst_iaddr_test( &dst_iaddr ) ){
DBG("received packet for which im unable to find a rdvpoint\n" );
return;
}
// if a establishing tunnel exists, update the trigerring packet
if( tunnel ){
DBG_ASSERT( tunnel->itor );
// update the trigger packet
onet_tunnel_itor_trigger_pkt_set( tunnel, ethertype, pkt, pkt_len );
DBG("tunnel is currently in establishement for this packet\n");
return;
}
DBG_ASSERT( !tunnel );
// create a tunnel as itor
tunnel = onet_tunnel_open_itor( &dst_iaddr );
if( !tunnel ){
LOGM_ERR("can't initiate a tunnel toward the iaddr %s\n", ip_addr_str( &dst_iaddr ) );
return;
}
// set the trigger packet
onet_tunnel_itor_trigger_pkt_set( tunnel, ethertype, pkt, pkt_len );
}
示例15: AllowClobber
/** True if the option can be overwritten */
bool AllowClobber() const
{
DBG_ASSERT(initialized_);
return allow_clobber_;
}