Thread: dll : design issue!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66

    dll : design issue!

    hi there,

    i'm not that experienced with dll's... so please bear with me on this one... basically i have a design question for you...

    the scenario is this: i have a library that i want to distribute to someone as a dll, so they can use part of the functionality of the library... but only a very small part of it... so what i planned to do is have a wrapper around one class in the library that would allow limited access to a single class in the library...

    this is a basic example of how i thought i could do it:

    Code:
    /////////////////////////////////////////////////////////
    //the original library class
    
    class SpecialImage
    {
        public:
    
            SpecialImage();
            ~SpecialImage();
    
            int openSpecialImage(char* filename);
            int getSpecialImageColour(int x, int y);
    
        private:
    
            Image image;
            int special_number;
    };
    
    /////////////////////////////////////////////////////////
    
    /////////////////////////////////////////////////////////
    //the exported dll 'wrapper' class
    
    #include "SpecialImage.h"
    
    class class __declspec(dllexport) ExportedSpecialImage
    {
        public: 
            
            ExportedSpecialImage();
            ~ExportedSpecialImage();
    
            int openExportedSpecialImage(char* filename);
            int getExportedSpecialImageColour(int x, int y);
    
        private:
            
            SpecialImage* special_image;
    };
    
    ///and in the ExportedSpecialImage.cpp
    ExportedSpecialImage::ExportedSpecialImage()
    {
        special_image = NULL;
    }
    ExportedSpecialImage::~ExportedSpecialImage()
    {
        if(special_image!=NULL)delete special_image;
    }
    
    int ExportedSpecialImage::openExportedSpecialImage(char* filename)
    {
        specialImage->openSpecialImage(filename);
    }
    
    int ExportedSpecialImage::getExportedSpecialImageColour(int x, int y)
    {
        return special_image->getSpecialImageColour(x, y);
    }
    /////////////////////////////////////////////////////////

    the problem is that in my ExportedSpecialImage.h file, i need to import the 'SpecialImage.h" and i also have a member variable of type 'SpecialImage'... which would mean i could not just send the .dll and 'ExportedSpecialImage.h'.... i would also have to send 'SpecialImage.h'.... and whatever header files it depends on.... wouldn't I?? so basically i want to limit the exposure of 'SimpleImage' somehow....

    so that's my dilemma... how to do this 'wrapper' class... without exposing anymore of the library than necessary...? does that make any sense?

    it may be that i am just being stupid... but i can't figure out how to do this one.... any help/thoughts greatly appreciated!! thanks.
    Last edited by dug; 02-16-2005 at 11:25 AM.
    "take the long road.... and walk it."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DLL Load issue
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 09-01-2007, 03:42 PM
  2. Replies: 3
    Last Post: 11-16-2006, 04:23 AM
  3. dll issue
    By axr0284 in forum C++ Programming
    Replies: 1
    Last Post: 03-23-2006, 08:37 AM
  4. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  5. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM