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

C / C++ / MFC

 
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 
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 
I took your advice. Hopefully i executed it correctly, here is the updated snippet. I still use CPluginObject template with the std::shared_ptr implementation because it looks better to type CPluginObject<num> than CreatePluginClass(num, classPtr) or would this be bad development schematics?

typedef std::shared_ptr<IPlugin> IPluginPtr;

<pre>void CreatePluginClass(int iid, IPluginPtr &pObj)
{
   if (iid == PLUGIN_CLASS_1)
      pObj = IPluginPtr(new TestPlugin1());
   if (iid == PLUGIN_CLASS_2)
      pObj = IPluginPtr(new TestPlugin2());
}


template<int N>
class CPluginObject {
public:
CPluginObject() {
CreatePluginClass(N, pPluginObj);
}
IPluginPtr GrabObject() {
return std::dynamic_pointer_cast<IPlugin>(pPluginObj);
}
protected:
IPluginPtr pPluginObj;
};

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

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

Eventually i want to use std::map so i dont always have to create pObj for calling other classes.

IPluginPtr GrabObject(std::string strImp)
{
   if (m_ClassManager.count[strImp])
      return std::dynamic_pointer_cast<IPlugin>(m_ClassManager[strImp]);
}


and to call the class
GrabObject("TestClass1")->Function1();
GrabObject("TestClass1")->Function2();


well something in the sorts of this

modified on Sunday, August 1, 2010 2:58 PM

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 
GeneralRe: Child Dialog Pin
Gary R. Wheeler31-Jul-10 23:43
Gary R. Wheeler31-Jul-10 23:43 
AnswerRe: Child Dialog Pin
Sauro Viti31-Jul-10 22:25
professionalSauro Viti31-Jul-10 22:25 
QuestionBalloon notification in Vista Pin
rahul.kulshreshtha30-Jul-10 20:38
rahul.kulshreshtha30-Jul-10 20:38 
Questionhow does this macro work? Pin
Amrit Kshetri30-Jul-10 16:06
Amrit Kshetri30-Jul-10 16:06 
AnswerRe: how does this macro work? Pin
Paul M Watt30-Jul-10 17:17
mentorPaul M Watt30-Jul-10 17:17 

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.