c++ native code DLL using an abstract class into a wrapper to be used in C# module

Viewed 589

Hi i am having the same problem with abstract class.i am trying to wrap my cpp Dll calls to use in the C# module.

Dll is using the Factory pattern.which contain a class Factory,MiddileWare ,And their costrong textrresponding child class.Could any one help me to start the wrapper. i am stuck in between this.Your help will be appreciated. i am giving the flow here:

MiddleWareFactory.h

#pragma once
#include "MiddleWareConnection.h"
#include "std afx.h"

  #ifdef MIDDLEWAREFACTORY_EXPORTS
#define MIDDLEWAREFACTORY_API __declspec(dllexport)
#else

#define MIDDLEWAREFACTORY_API __declspec(dllimport) #endif

  MIDDLEWAREFACTORY_API enum eMiddleWareEngine
      {
          eRabitMQ = 0,  
          eZeroMQ,                           
          eActiveMQ          

        };
     // This class is exported from the MiddleWareFactory.dll

      class MIDDLEWAREFACTORY_API CMiddleWareFactory
      {
      public:
         CMiddleWareFactory(void);
         ~CMiddleWareFactory();
        // TODO: add your methods here.

        //Function to Create the  object of Broker module:implemnted the                   Factory   concept.
      BOOL CreateInstance(CMiddleWareConnection** pMObj);
     int m_eMomEngine;//To define which MOM need to enable.

};



extern MIDDLEWAREFACTORY_API int nMiddleWareFactory;

MIDDLEWAREFACTORY_API int fnMiddleWareFactory(void);

MiddleWareConnection.h

#pragma once

class CMiddleWareConnection { public:

  virtual ~CMiddleWareConnection(void)
  {
   }
  //Pure virtual fuctions for interfacing 
  virtual BOOL Connect(int nServerType)=0;
   virtual BOOL CreateSessionExchange() = 0;
   virtual BOOL CreateQueue(LPCTSTR lpszQueueName) = 0;
   virtual BOOL Disconnect() = 0;
   virtual BOOL Send(void *MomItem,LPCTSTR lpszKey, int               &nSendCount)=0;
   virtual BOOL Receive() = 0;
   virtual void StopReceiver() = 0;
   virtual void GetData(void* pMsg, int &nMsgLen,int nMsgType,int &nReceiveCount)=0;
   };

RabbitMQ.h

  #pragma once
  #include "MiddleWareConnection.h"
  #include "Amqp.h"
  #pragma comment(lib, "rabbitmq.4.lib")
  #define GET_DATA(a){memcpy(&a, pDataPtr,  sizeof(a));pDataPtr+=sizeof(a);}
  #define GET_DATA_EX(s,n){memcpy(s, pDataPtr, n);pDataPtr+=n;}

 typedef struct _ROUTINE_KEY
{
 CString RoutingKey;             

 }ROUTEKEY, *LPROUTEKEY;

   class CRabbitMQ :
   public CMiddleWareConnection
      {
          public:

      CRabbitMQ(CAppConfig &rConfig);
     ~CRabbitMQ();
      void   InitializeRBMQ(CAppConfig &rConfig);//Initialize RBMQ Config;
         BOOL   Connect(int nServerType);
         BOOL   Disconnect(void);
         BOOL   Send(void *MomItem, LPCTSTR lpszKey, int &nSendCount);
         BOOL   Receive(void);
         BOOL   CreateQueue(LPCTSTR lpszQueueName);
         BOOL   CreateSessionExchange();
         BOOL   BindQueue(LPCTSTR lpszQueue, LPCTSTR lpszExchangeName, LPCTSTR lpszKey);
         bool   IsConnected(){return m_bConnected;}
         void   SetKeyQueueCombination( TCHAR *pszQueueName, TCHAR *pszRoutingKey);
         void   StopReceiver();
         bool   ReEstablishRMQMWConnection();
        void   GetData(LPBYTE &pMsg, int &nMsgLen,int &nReceiveCount);
        void   GetData(void* pMsg, int &nMsgLen,int nMsgType,int &nReceiveCount);
     BOOL   GetNext_JasonListItem(LPJASON_ITEM pItem);
      LPRABBIT_MQ_ITEM GetNextItem();

      };

Here i want to expose the rabbitMq class functions[Connect,send,Recieve ete from MiddleWareConnection.h to C# module.

Thanks

3 Answers
Related