CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Inherit debug value in derived class?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 10, 2016, 10:08
Default Inherit debug value in derived class?
  #1
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
Is there a way to do this? I have slight variations of a model that I would like to be able to turn on debugging for by "flipping" the switch of the base class.
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Old   January 10, 2016, 17:18
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Pete,

An example would make it easier to give a counter example and to test it to be certain of it...
Anyway, in theory, simply use the usual "access methods and variables from the parent class by calling it directly". For example, if you have something that is somehow derived from "fvPatchField", you should be able to simply do:
Code:
fvPatchField::debug = 1;
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   January 10, 2016, 22:56
Default
  #3
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
Thanks for your insight Bruno!

This seems to suit my needs (inside constructor for derived class):

Code:
    if (not debug and baseClass::debug)
    {
        debug = baseClass::debug;
    }
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Old   January 11, 2016, 08:19
Default
  #4
Senior Member
 
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13
pbachant is on a distinguished road
There is an issue with using this method, however. You can turn on debugging using the switch for the base class, but you can't turn it off.
__________________
Home | Twitter | GitHub
pbachant is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The udf.h headers are unable to open- in VISUAL STUDIO 13 sanjeetlimbu Fluent UDF and Scheme Programming 4 May 2, 2016 05:38
How are the integration constants for the JANAFthermo class derived? tomf OpenFOAM Running, Solving & CFD 2 May 15, 2015 07:47
OF-2.2.x: Derived class from cellZone and "undefined symbol error" A_Pete OpenFOAM Programming & Development 6 April 28, 2014 01:53
How to access solver fields from fvPatchField%2360Type derived class that defines BC kar OpenFOAM Running, Solving & CFD 0 February 29, 2008 12:41
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30


All times are GMT -4. The time now is 07:30.