Action #493

Feature #490: Avoid casts for derived classes

Rework GInstDir interface

Added by Knödlseder Jürgen about 12 years ago. Updated almost 12 years ago.

Status:ClosedStart date:09/20/2012
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-Estimated time:0.00 hour
Target version:00-07-00
Duration:

Recurrence

No recurrence.

History

#1 Updated by Knödlseder Jürgen about 12 years ago

  • Start date set to 09/20/2012

due to changes in a related task

#2 Updated by Knödlseder Jürgen about 12 years ago

  • Assigned To set to Knödlseder Jürgen

#3 Updated by Knödlseder Jürgen almost 12 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100
  • Remaining (hours) set to 0.0

All casts in the instrument specific classes have been removed. No rework has been done on the GInstDir interface. Not clear whether we really need a rework, as long as we don’t have the need for a cast.

#4 Updated by Knödlseder Jürgen almost 12 years ago

  • Estimated time set to 0.00

I did not manage to circumvent casting :(

Here’s what I added for the moment to the GCTAInstDir class:

%extend GCTAInstDir {
    GCTAInstDir(GInstDir* dir) {
        GCTAInstDir* ptr = dynamic_cast<GCTAInstDir*>(dir);
        if (ptr != NULL) {
            return (ptr->clone());
        }
        else {
            throw GException::bad_type("GCTAInstDir(GInstDir*)",
                                       "GInstDir not of type GCTAInstDir");
        }
    }
};

The only advantage with respect to the former implementation is that it is nicer ...

Also available in: Atom PDF