Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8363111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:06:05+00:00 2026-06-09T12:06:05+00:00

I’m writing an application that is mapping out a directory structure that needs to

  • 0

I’m writing an application that is mapping out a directory structure that needs to hold as much information about each file as possible so the end user can them apply custom filters for manipulating the files and folders within. The Class that also does the file searching provides basic information back to the UI to give the end user an idea of how much data is involved. What I am trying to accomplish is recursion in to the sub objects of the class via properties to get the information that I need so that I only ever have to access the top level class to get requiered the information and not have to worry about the information in any number of sub classes.

type 
  TSomeClass = class(TObject)
  private    
    FContainerForSubObjects: TObjectList<TSomeClass>;
    FSomethingToBeCounted: Integer;
    FHasTheDataChanged: Boolean;
  private
    function GetSomethingToBeCounted: Integer;
    function GetHasTheDataChanged: Boolean;
  public
    property SomethingToBeCounted: Integer read GetSomethingToBeCounted;
    property HasTheDataChanged: Boolean read GetHasTheDataChanged;

To make the class declaration make a little more sense. Look at it like this. The ContainerForSubObjects contains a folder so if you were to look at your hard drive the root class would be C:\ if there was a folder called data there would be a sub object that represented the C:\Data folder and the SomethingToBeCounted would be the number of files in each folder.

Now what I want to do in the GetSomethingToBeCounted function if as follows

  1. See if there are any Sub Objects (Which is easy the part)
  2. if there are Sub Objects, Query their SomethingToBeCounted property which in turn should call the GetSomethingToBeCounted function to return the value of the FSomethingToBeCounted field of the class BUT the function should act according to the condition of the HasTheDataChanged state of the class This is where I’m hoping recursion will kick in
    • if the HasTheDataChanged property is set to false for any contained Sub Objects is up to date then it should return it’s value and no more processing should be done
    • if the HasTheDataChanged property is set to true data is not up to date and it should be recalculated and the new recalculated value returned. It should also set the appropriate HasTheDataChanged state so it reduces further reprocessing.

I’m also assuming that this similar type of propagation would have to be done with the HasTheDataChanged property as well so that if a value changes somewhere in the middle of the tree all parent objects would be updated accordingly.

Hopefully those requirements make sense

Now to the meat of the question. First of all. is my thinking correct and that just by accessing the sub objects properties that the correct values will propagate their way up to root object so I don’t have to spend countless lines of code searching each sub object when there could be thousands of sub objects. Or is it a case that I’m trying to reinvent the wheel here and I’m just over looking a class that already exists and could be using instead of making my own. and Last but not least. would this be the most efficient way of doing things?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:06:07+00:00Added an answer on June 9, 2026 at 12:06 pm

    I haven’t come across an existing component that does what you want so writing your own seems to be sound.

    Your method will work and is one that I have used myself many times. You have a recursive data structure in that TSomeClass contains a list of further TSomeClass objects. Traversing this structure in any other way would be more complex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.