text: /*
   *  pubsubpluginAWSSQS: Generic GUCEF COMCORE plugin for providing pubsub via AWS's SQS
   *
   *  Copyright (C) 1998 - 2020.  Dinand Vanvelzen
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *    http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  
  #ifndef PUBSUBPLUGIN_AWSSQS_CAWSSQSPUBSUBCLIENT_H
  #define PUBSUBPLUGIN_AWSSQS_CAWSSQSPUBSUBCLIENT_H
  
  /*-------------------------------------------------------------------------//
  //                                                                         //
  //      INCLUDES                                                           //
  //                                                                         //
  //-------------------------------------------------------------------------*/
  
  #include <aws/core/Aws.h>
  #include <aws/sqs/SQSClient.h>
  
  #ifndef GUCEF_CORE_CTIMER_H
  #include "CTimer.h"
  #define GUCEF_CORE_CTIMER_H
  #endif /* GUCEF_CORE_CTIMER_H ? */
  
  #ifndef GUCEF_CORE_CTHREADPOOL_H
  #include "gucefCORE_CThreadPool.h"
  #define GUCEF_CORE_CTHREADPOOL_H
  #endif /* GUCEF_CORE_CTHREADPOOL_H ? */
  
  #ifndef GUCEF_COMCORE_CPUBSUBCLIENT_H
  #include "gucefCOMCORE_CPubSubClient.h"
  #define GUCEF_COMCORE_CPUBSUBCLIENT_H
  #endif /* GUCEF_COMCORE_CPUBSUBCLIENT_H ? */
  
  #ifndef GUCEF_COMCORE_CPUBSUBCLIENTFACTORY_H
  #include "gucefCOMCORE_CPubSubClientFactory.h"
  #define GUCEF_COMCORE_CPUBSUBCLIENTFACTORY_H
  #endif /* GUCEF_COMCORE_CPUBSUBCLIENTFACTORY_H ? */
  
  #ifndef PUBSUBPLUGIN_AWSSQS_CAWSSQSPUBSUBCLIENTTOPIC_H
  #include "pubsubpluginAWSSQS_CAwsSqsPubSubClientTopic.h"
  #define PUBSUBPLUGIN_AWSSQS_CAWSSQSPUBSUBCLIENTTOPIC_H
  #endif /* PUBSUBPLUGIN_AWSSQS_CAWSSQSPUBSUBCLIENTTOPIC_H ? */
  
  /*-------------------------------------------------------------------------//
  //                                                                         //
  //      NAMESPACE                                                          //
  //                                                                         //
  //-------------------------------------------------------------------------*/
  
  namespace GUCEF {
  namespace PUBSUBPLUGIN {
  namespace AWSSQS {
  
  /*-------------------------------------------------------------------------//
  //                                                                         //
  //      CLASSES                                                            //
  //                                                                         //
  //-------------------------------------------------------------------------*/
  
  class PUBSUBPLUGIN_AWSSQS_PLUGIN_PRIVATE_CPP CAwsSqsPubSubClient : public COMCORE::CPubSubClient
  {
      public:
  
      static const CORE::CString TypeName; 
  
      CAwsSqsPubSubClient( const COMCORE::CPubSubClientConfig& config );
  
      virtual ~CAwsSqsPubSubClient() GUCEF_VIRTUAL_OVERRIDE;
  
      virtual bool GetSupportedFeatures( COMCORE::CPubSubClientFeatures& features ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual const COMCORE::CPubSubClientTopicConfig* GetTopicConfig( const CORE::CString& topicName ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual COMCORE::CPubSubClientTopic* CreateTopicAccess( const COMCORE::CPubSubClientTopicConfig& topicConfig ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual COMCORE::CPubSubClientTopic* GetTopicAccess( const CORE::CString& topicName ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual void DestroyTopicAccess( const CORE::CString& topicName ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual bool GetAvailableTopicNameList( CORE::CString::StringSet& topicNameList                                            ,
                                              const CORE::CString::StringSet& globPatternFilters = CORE::CString::EmptyStringSet ) GUCEF_VIRTUAL_OVERRIDE;
      
      virtual void GetConfiguredTopicNameList( CORE::CString::StringSet& topicNameList ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual void GetCreatedTopicAccessNameList( CORE::CString::StringSet& topicNameList ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual bool Connect( void ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual bool Disconnect( void ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual bool IsConnected( void ) GUCEF_VIRTUAL_OVERRIDE;
  
      virtual const CORE::CString& GetType( void ) const GUCEF_VIRTUAL_OVERRIDE;
  
      virtual bool SaveConfig( CORE::CDataNode& tree ) const GUCEF_VIRTUAL_OVERRIDE;
  
      virtual bool LoadConfig( const CORE::CDataNode& treeroot ) GUCEF_VIRTUAL_OVERRIDE;
  
      COMCORE::CPubSubClientConfig& GetConfig( void );
  
      Aws::SQS::SQSClient& GetSqsClient( void );
      
      private:
  
      void
      OnMetricsTimerCycle( CORE::CNotifier* notifier    ,
                           const CORE::CEvent& eventId  ,
                           CORE::CICloneable* eventData );
  
      void RegisterEventHandlers( void );
      
      CAwsSqsPubSubClient( void ); /**< not implemented */
  
      private:
  
      typedef CORE::CTEventHandlerFunctor< CAwsSqsPubSubClient > TEventCallback;
      typedef std::map< CORE::CString, CAwsSqsPubSubClientTopic* > TTopicMap;
  
      COMCORE::CPubSubClientConfig m_config;
      CORE::CTimer* m_metricsTimer;
      TTopicMap m_topicMap;
      Aws::SQS::SQSClient m_sqsClient;    
  };
  
  /*-------------------------------------------------------------------------//
  //                                                                         //
  //      NAMESPACE                                                          //
  //                                                                         //
  //-------------------------------------------------------------------------*/
  
  }; /* namespace AWSSQS */
  }; /* namespace PUBSUBPLUGIN */
  }; /* namespace GUCEF */
  
  /*--------------------------------------------------------------------------*/
  
  #endif /* PUBSUBPLUGIN_AWSSQS_CAWSSQSPUBSUBCLIENT_H ? */
  