Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: RichEdit control in Dialog: "Retrun" does'nt Work ! Pin
stephen_young1-Aug-10 12:23
stephen_young1-Aug-10 12:23 
AnswerRe: RichEdit control in Dialog: "Retrun" does'nt Work ! Pin
Code-o-mat1-Aug-10 8:14
Code-o-mat1-Aug-10 8:14 
GeneralRe: RichEdit control in Dialog: "Retrun" does'nt Work ! Pin
stephen_young1-Aug-10 12:26
stephen_young1-Aug-10 12:26 
GeneralRe: RichEdit control in Dialog: "Retrun" does'nt Work ! Pin
Code-o-mat1-Aug-10 21:54
Code-o-mat1-Aug-10 21:54 
QuestionHow do I dock panes stacked on top of each other? Pin
Mattias G1-Aug-10 3:11
Mattias G1-Aug-10 3:11 
AnswerRe: How do I dock panes stacked on top of each other? Pin
Mattias G1-Aug-10 3:15
Mattias G1-Aug-10 3:15 
GeneralRe: How do I dock panes stacked on top of each other? Pin
Iain Clarke, Warrior Programmer3-Aug-10 2:12
Iain Clarke, Warrior Programmer3-Aug-10 2:12 
QuestionPlugin Abstract Interface idea Pin
saiyuk6=731-Jul-10 23:23
saiyuk6=731-Jul-10 23:23 
I have a question i want to create a plugin manager, and i have a small example test-bed written. It has abstract classes.

The function CreatePluginClass will the main function to control a set of mini classes that will use the same Interface IPlugin and create a Pointer stored into memory for the new class that will eventually have to be released, so i made a auto/release type template class to do that for me CPluginObject as you can see in the example entry main function

Will this be reliable, because i kinda want to go through this type of approach and if something wrong with this can someone help me point out what it could be?, so far everything is fine that i can see but im not sure that later on that it will cause me problems, if anyone has done anything like this before. I would appreciate the helpful tips

when i tested it i get the results im looking for i guess in the console output shows
TestPlugin2::Function1
TestPlugin2::Function1


#include <stdio.h>

class IPlugin {
public:
   virtual void Function1() = 0;
   virtual void Function2() = 0;
};

class TestPlugin1 : public IPlugin {
public:
   virtual void Function1() {
      printf("TestPlugin1::Function1\n");
   }

   virtual void Function2() {
      printf("TestPlugin1::Function1\n");
   }
};

class TestPlugin2 : public IPlugin {
public:
   virtual void Function1() {
      printf("TestPlugin2::Function1\n");
   }

   virtual void Function2() {
      printf("TestPlugin2::Function1\n");
   }
};

#define PLUGIN_CLASS_1 100
#define PLUGIN_CLASS_2 100

void CreatePluginClass(int iid, IPlugin **pObj)
{
   *pObj = NULL;
   if (iid == PLUGIN_CLASS_1)
      *pObj = new TestPlugin1();
   if (iid == PLUGIN_CLASS_2)
      *pObj = new TestPlugin2();
}

template<int N>
class CPluginObject {
public:
   CPluginObject() {
      CreatePluginClass(N, &pPluginObj);
   }
   ~CPluginObject() {
      if (pPluginObj != NULL)
         delete pPluginObj;
      pPluginObj = NULL;
   }

   IPlugin *GrabObject() const {
      return pPluginObj;
   }
protected:
   IPlugin *pPluginObj;
};

void main(void)
{
	   CPluginObject<PLUGIN_CLASS_1> plugin;
	   IPlugin *pObj = plugin.GrabObject();

	   pObj->Function1();
	   pObj->Function2();
}


modified on Sunday, August 1, 2010 5:36 AM

AnswerRe: Plugin Abstract Interface idea PinPopular
Moak1-Aug-10 0:55
Moak1-Aug-10 0:55 
GeneralRe: Plugin Abstract Interface idea Pin
saiyuk6=71-Aug-10 8:47
saiyuk6=71-Aug-10 8:47 
GeneralRe: Plugin Abstract Interface idea Pin
Aescleal1-Aug-10 11:40
Aescleal1-Aug-10 11:40 
AnswerRe: Plugin Abstract Interface idea Pin
Aescleal1-Aug-10 6:58
Aescleal1-Aug-10 6:58 
GeneralRe: Plugin Abstract Interface idea Pin
saiyuk6=71-Aug-10 8:34
saiyuk6=71-Aug-10 8:34 
GeneralRe: Plugin Abstract Interface idea Pin
Aescleal1-Aug-10 11:24
Aescleal1-Aug-10 11:24 
AnswerRe: Plugin Abstract Interface idea Pin
KarstenK1-Aug-10 20:51
mveKarstenK1-Aug-10 20:51 
GeneralRe: Plugin Abstract Interface idea Pin
saiyuk6=71-Aug-10 22:43
saiyuk6=71-Aug-10 22:43 
QuestionChild Dialog Pin
john563231-Jul-10 0:31
john563231-Jul-10 0:31 
AnswerRe: Child Dialog Pin
Cool_Dev31-Jul-10 0:54
Cool_Dev31-Jul-10 0:54 
AnswerRe: Child Dialog Pin
Richard MacCutchan31-Jul-10 0:55
mveRichard MacCutchan31-Jul-10 0:55 
GeneralRe: Child Dialog Pin
Cool_Dev31-Jul-10 1:11
Cool_Dev31-Jul-10 1:11 
GeneralRe: Child Dialog Pin
Richard MacCutchan31-Jul-10 1:57
mveRichard MacCutchan31-Jul-10 1:57 
GeneralRe: Child Dialog Pin
Cool_Dev31-Jul-10 2:06
Cool_Dev31-Jul-10 2:06 
GeneralRe: Child Dialog Pin
Richard MacCutchan31-Jul-10 3:06
mveRichard MacCutchan31-Jul-10 3:06 
GeneralRe: Child Dialog Pin
Gary R. Wheeler31-Jul-10 10:25
Gary R. Wheeler31-Jul-10 10:25 
GeneralRe: Child Dialog Pin
Richard MacCutchan31-Jul-10 21:23
mveRichard MacCutchan31-Jul-10 21:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.