Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solution To Type Fields

Status
Not open for further replies.

ColoradoBill

Programmer
Dec 23, 2004
1
US
Hello I am creating a small imaging library. When I load an image from file I don't know until the header is read how many samples are in each pixel. For example if I load a JPEG it may be grayscale (8 bit pp) or rgb (24 bit pp). In addition, I have added the option for the client to specify an RGB or BGR pixel layout in the constructor of all the ImageReader classes in the hirearchy. Since other classes utilize my ImageReader's and iterate through all the pixels they need to know the layout of the pixels including the number of bands and RGB vs. BGR. The way I have been dealing with this so far is to use type fields for the pixel layout. Unfortunately every time I add a new ImageReader I need to update all the switch statements that check the type field for pixel layout. What are some object oriented solutions to this problem? Obviously inheritance and virtul functions would be an option but I would still need the switch statements to check the type (using dynamic_cast or typeid) of each ImageReader in order to properly iterate through the pixels.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top