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

Inheritance in DynamicList<Type>

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Santiago

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 30, 2020, 11:29
Default Inheritance in DynamicList<Type>
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 352
Rep Power: 11
Gerry Kan is on a distinguished road
Howdy Foamers:

I am scratching my head on this. I am using a DynamicList in my solver implementation. According to the OpenFOAM API, DynamicList is inherited from List, which is in turn inherited from UList.

List has a public member append(), while UList has a public member find(). In theory both should be accessible from my instance of DynamicList.

However, while calling DynamicList::append() compiled without problem, the compiler complained about DynamicList not being to access find(). This behavior is consistent with all member functions in List (no errors) and UList (compiler errors). This leads me to believe this could be an issue with my understanding with the C++ language.

I am wondering if I am missing something, and how could I access the find function from DynamicList?

Thanks in advance, Gerry.
Gerry Kan is offline   Reply With Quote

Old   July 30, 2020, 13:03
Default
  #2
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 352
Rep Power: 11
Gerry Kan is on a distinguished road
A few notes, kinda strange:

1) find () is not in UList in the distribution I am using (OF 7), while it is according to the 2006 API. Strange, but I guess my assumption is wrong, where the implementation for the very basic classes are supposedly identical between .org and .com.

2) Looks like you do need to refer to the base class when calling one of its member functions, i.e., myDynamicList.UList::find(), assuming the member find() is here.

Gerry.
Gerry Kan is offline   Reply With Quote

Old   July 31, 2020, 10:03
Default
  #3
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 352
Rep Power: 11
Gerry Kan is on a distinguished road
Okay, i ended up implementing the find member function in the .org flavor of UList. I am still scratching my head as to why the basic data structure are differently implemented.
Gerry Kan is offline   Reply With Quote

Old   July 31, 2020, 10:19
Default
  #4
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
Quote:
Originally Posted by Gerry Kan View Post
Okay, i ended up implementing the find member function in the .org flavor of UList. I am still scratching my head as to why the basic data structure are differently implemented.
FOAM was conceived in a time where STL wasnt as mature, so many basic containers were implemented directly as to avoid library performance issues. An example is the autoPtr<> handle, which in some forks of FOAM is beibg slowly converted to std::auto_ptr.
Gerry Kan likes this.
Santiago 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
Multiple inheritance paradigms in OpenFOAM raumpolizei OpenFOAM Programming & Development 3 January 4, 2019 08:16
function objects and virtual inheritance MichiB OpenFOAM Programming & Development 1 September 15, 2015 19:29
Virtual inheritance problem while adding public member function to LES SGS Model konneym OpenFOAM Programming & Development 4 November 4, 2013 11:37
inheritance and collaboration diagrams, hawkeye321 OpenFOAM 1 March 2, 2013 06:06
Multiple inheritance, function pointers or? ngj OpenFOAM 0 March 20, 2009 10:36


All times are GMT -4. The time now is 18:57.