/** * @file include/ActivMiddleware/ActivAgentApplication/DirectoryService.h * * @brief Header file for directory service class. */ #if (!defined ACTIV_AGENT_APPLICATION_DIRECTORY_SERVICE_H) #define ACTIV_AGENT_APPLICATION_DIRECTORY_SERVICE_H #include "ActivMiddleware/ActivAgentApplication/External.h" #include "ActivMiddleware/ActivFramework/Service.h" #include ACTIV_BOOST_INCLUDE(scoped_ptr.hpp) //! Activ namespace. namespace Activ { //! DirectoryService. class DirectoryService : private ManagedEndPoint { public: //! Settings. class Settings { public: //! Default constructor. ACTIV_AGENT_APPLICATION_API Settings(); /** * @brief Read settings from an ini file section. * * @param sectionIterator iterator to an ini file section. * * @throw Exception */ ACTIV_AGENT_APPLICATION_API void Read(const IniFileParser::ConstSectionIterator §ionIterator); bool m_shouldEnablePubSubMulticast; ///< Default: true. Whether pub-sub over multicast is enabled. IHeap::Settings m_heapSettings; ///< Heap properties for directory service, default buckets above. ManagedEndPoint::Settings m_managedEndPointSettings; String m_serviceAttributes; ///< Attributes for service when publishing existence of this DirectoryService. std::vector m_servicePortList; ///< List of TCP ports to attempt to listen on. The list will be randomized and then iterated until a free port is found. // Discovery of other DirectoryServices. std::vector m_discoveryAttributeQueryList; ///< Only interested in other DirectoryServices which advertise with attributes that match one of these queries. size_t m_cleanupServicesTimeout; ///< How long after the connection to a DirectoryService is lost to remove its services, in seconds. size_t m_ttl; ///< TTL of discovery multicast. Default: 3. ServiceInstanceList m_remoteDirectoryServiceInstanceList; ///< Configured list of remote directory services to add, pub-sub over multicast must be disabled. // Conversion of hostnames in attributes. std::vector m_hostConversionAttributeKeyList; ///< List of attribute keys that might contain hostnames that need converting to ip addresses for remote directories. std::vector m_urlConversionAttributeKeyList; ///< List of attribute keys that might contain URLs that contain hostnames that need converting to ip addresses for remote directories. }; //! Ui component. class UiComponent ACTIV_FINAL : public Activ::UiComponent { public: /** * @brief Constructor. * * @param directoryService object to show menu for. * @param uiServiceName name of the ui service. * * @throw Exception. */ ACTIV_AGENT_APPLICATION_API UiComponent(DirectoryService &directoryService, const String &uiServiceName); private: virtual void Run(UiUser &uiUser) ACTIV_OVERRIDE; DirectoryService & m_directoryService; // Last member. Component::Enabler m_componentEnabler; }; /** * @brief Constructor. * * @param application Application object to attach to. * @param serviceName name of the service. * @param settings settings for directory service. * @param serviceLocationIniFile filename of ini file containing static services. * * @throw Exception. */ ACTIV_AGENT_APPLICATION_API DirectoryService(Application &application, const String &serviceName, const Settings &settings, const String &serviceLocationIniFile); //! Destructor. ACTIV_AGENT_APPLICATION_API ~DirectoryService(); class Impl; private: static CxxYZ::unique_ptr MakeImpl(DirectoryService &directoryService, const String &serviceName, const Settings &settings, const String &serviceLocationIniFile); CxxYZ::unique_ptr m_pImpl; }; } // namespace Activ #endif // (!defined ACTIV_AGENT_APPLICATION_DIRECTORY_SERVICE_H)