DataSubscribe.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "DataSubscribe.h"
  2. #include <QVariant>
  3. #include "LibraryLoader.h"
  4. #include "Publisher.h"
  5. #include <QDebug>
  6. DataSubscribe::DataSubscribe()
  7. {
  8. //shares = new SharedData();
  9. }
  10. DataSubscribe::~DataSubscribe()
  11. {
  12. //delete shares;
  13. }
  14. void DataSubscribe::Setup(ModuleInfo &mi)
  15. {
  16. std::string assemblyName = mi.AssemblyName;
  17. dataName = mi.Name;
  18. Publisher* pModule = nullptr;// = (BaseModule)Assembly.LoadFile(Path.GetFullPath(@".\" + assemblyName)).CreateInstance(className);
  19. pModule = LibraryLoader::load<Publisher>(assemblyName);
  20. if( pModule == nullptr )
  21. {
  22. // qCritical() << LOG_HEADER << " load " << szPlugin.c_str() << " failed.";
  23. return;
  24. }
  25. if( pModule == nullptr )
  26. {
  27. qCritical() << __FILE__ << __LINE__ << " " << assemblyName.c_str() << " load failed.";
  28. return;
  29. }
  30. {
  31. Publisher* runable = dynamic_cast<Publisher*>(pModule);
  32. //runable->shares(shares);
  33. for(auto it = dataConsumerList.begin(); it != dataConsumerList.end(); it++){
  34. connect(runable, SIGNAL(pubData(const QString& ,const QString& ,const QVariant& )), *it, SLOT(OnData(const QString& ,const QString& ,const QVariant&)));
  35. }
  36. runable->Run();
  37. }
  38. }
  39. std::string DataSubscribe::getTypeList()
  40. {
  41. return "DataStorage::RunnableModule";
  42. }
  43. // void DataSubscribe::setLoader(QLibrary *)
  44. // {
  45. // }
  46. void DataSubscribe::regConsumer(DataConsumer *dc)
  47. {
  48. dataConsumerList.append(dc);
  49. qDebug() << "register consumer";
  50. }