Difference: HowToManageclassIndex (r3 vs. r2)

Question

Hi there!

There is a class variable as 'classIndex' for every class derived from 'ProcessingClass', and it is initialized with a const value. I believe we can identify every class instances for the class by this strategy.

When I add new 'ProcessingClass', how can I select the 'classIndex' to ensure it is the only one and won't be confict with others?

Regards,

Wei Yan

-- YanWei - 06 Mar 2010

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

Hi Yan!

As you correctly guessed, the 'classIndex' variable identifies every class instances. I keep a record of those indexes, and if you add a new 'ProcessingClass' please get in touch with me.

However, I must confess that currently I think that the 'classIndex' approach is a BAD IDEA (and it was my idea, by the way smile ).

As I learned more about C++, I realized that the implementation of 'classIndex' using a static class variable may severely impair attempts to use these classes in a parallel computing environment, because it is not scalable.

Additionally, after using the 'ProcessingClasses' for a long time I've found yet no case where the use of 'classIndex' is providing me any advantage.

In summary, one of the issues I'll address in the near future is to eliminate the 'classIndex' feature from all 'ProcessingClasses' (I'll keep the 'getClassName()' feature, because it does no harm).

If you have any comments in this regard, I'll be glad to hear them.

Cheers,

Dago

-- DagobertoSalazar - 01 Mar 2011 No such template def TMPL:DEF{PROMPT:supportquery}

Hi Dago!

Sometimes, the 'classIndex' is useful in a parallel computing environment. For example, one may want to save some data to a file with parallel computing, then he can get a unique file name by 'classIndex' for every instance of the class. I work in this way in a GNSS simulation software project for the government, and I learn it from your design of 'ProcessingClass' smile .

However, I?m agree with you to eliminate the 'classIndex' feature from all 'ProcessingClasses', that will easy our developing work and get rid of handing of those 'classIndex'. If we need this feature in future, we can write some wrapper classes.

Thanks for your great work of 'GDS' structures, I really love it!

Cheer,

Wei Yan

-- YanWei - 10 Mar 2011 No such template def TMPL:DEF{PROMPT:supportquery}

View topic | View difference side by side | History: r3 < r2 < r1 | More topic actions
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback