Changeset 506d2f for src/Helpers
- Timestamp:
- Aug 4, 2010, 2:43:44 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 680470
- Parents:
- 00fca3
- Location:
- src/Helpers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Helpers/Assert.cpp
r00fca3 r506d2f 59 59 const char* Assert::_wrapper::message_ref = "source reference did not contain object of desired type"; 60 60 61 bool Assert::_my_assert::check(const bool res, 62 const char* condition, 63 const char* message, 64 const char* filename, 65 const int line, 66 bool& ignore) 61 bool Assert::_my_assert::check(const char* condition, 62 const char* message, 63 const char* filename, 64 const int line, 65 bool& ignore) 67 66 { 68 if(!res){ 69 cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl; 70 cout << "Assertion Message: " << message << std::endl; 71 while(true){ 72 char choice; 73 if(defaultAction==Assert::Ask) { 67 cout << "Assertion \"" << condition << "\" failed in file " << filename << " at line " << line << endl; 68 cout << "Assertion Message: " << message << std::endl; 69 while(true){ 70 char choice; 71 if(defaultAction==Assert::Ask) { 74 72 #ifdef __GNUC__ 75 73 cout << "Please choose: (a)bort, (t)hrow execption, show (b)actrace, (i)gnore, al(w)ays ignore" << endl; 76 74 #else 77 75 cout << "Please choose: (a)bort, (t)hrow execption, (i)gnore, al(w)ays ignore" << endl; 78 76 #endif /* __GNUC__ */ 79 80 81 82 83 84 85 86 87 88 89 90 77 cin >> choice; 78 } 79 else{ 80 choice = ActionKeys[defaultAction]; 81 } 82 switch(choice){ 83 case 'a': 84 return true; 85 break; 86 case 't': 87 throw AssertionFailure(condition,filename,line,message); 88 break; 91 89 #ifdef __GNUC__ 92 93 94 90 case 'b': 91 Assert::_my_assert::backtrace(filename,line); 92 break; 95 93 #endif /* __GNUC__ */ 96 case 'w': 97 ignore = true; 98 // fallthrough 99 case 'i': 100 return false; 101 break; 102 } 94 case 'w': 95 ignore = true; 96 // fallthrough 97 case 'i': 98 return false; 99 break; 103 100 } 104 101 } -
src/Helpers/Assert.hpp
r00fca3 r506d2f 234 234 static bool ignore = false;\ 235 235 if(!ignore){\ 236 if( Assert::_my_assert::check((condition),STRINGIFY(condition),(message),\237 __FILE__,__LINE__,ignore)){\236 if(!(condition) && Assert::_my_assert::check(STRINGIFY(condition),(message),\ 237 __FILE__,__LINE__,ignore)){\ 238 238 Assert::_my_assert::doHooks();\ 239 239 DEBUG_BREAK;\ … … 247 247 static bool ignore = false; \ 248 248 if(!ignore){\ 249 if(Assert::_my_assert::check( false,"Exception caught",(message),__FILE__,__LINE__,ignore)){\249 if(Assert::_my_assert::check("Exception caught",(message),__FILE__,__LINE__,ignore)){\ 250 250 Assert::_my_assert::doHooks();\ 251 DEBUG_BREAK;\251 DEBUG_BREAK;\ 252 252 }\ 253 253 }\ … … 299 299 class _my_assert{ 300 300 public: 301 static bool check(const bool res, 302 const char* condition, 301 static bool check(const char* condition, 303 302 const char* message, 304 303 const char* filename, … … 335 334 336 335 if(!ignore){ 337 if(_my_assert::check(dynamic_cast<target>(src)==static_cast<target>(src),"type-safe typecast",338 336 bool res = dynamic_cast<target>(src)==static_cast<target>(src); 337 if(!res && _my_assert::check("type-safe typecast",message_ptr,file,line,ignore)){ 339 338 _my_assert::doHooks(); 340 339 DEBUG_BREAK; … … 357 356 catch(...){ 358 357 if(!ignore){ 359 if(_my_assert::check( 0,"type-safe typecast",message_ref,file,line,ignore)){358 if(_my_assert::check("type-safe typecast",message_ref,file,line,ignore)){ 360 359 _my_assert::doHooks(); 361 360 DEBUG_BREAK;
Note:
See TracChangeset
for help on using the changeset viewer.