Invoking correct function based on pointer

  • Thread starter Thread starter sgrm123
  • Start date Start date
S

sgrm123

Guest
Hi,

In my application, I am using MFC CFile operations in many places(some hundreds).

For few files(whcich are created under temp folder) I need to use CMemFile(it is derived from CFile) and for few files I need to use CFile.

Now my requirement is I should not change any files in the application wherever I am calling file operations lke open read, write, seektoend...

What I need to do is I need to create wrapper class derived from CMemFile.

class CFileWrapper : public CMemFile

{

};

In this class I need to differenciate that which file operations need to be called whether CMemFile's read function or CFile's read function.

I need to add macro to define CFile as CFileWrapper.

#define CFile CFileWrapper, whereever I am using CFile objects or pointers it will call CFileWrapper class.

Now my problem is inside CFileWrapper how to differciate which functions to call CMemFile or Cfile based on pointer.

Thanks,

Continue reading...
 
Back
Top