Files
externals/linux/include/ActivMiddleware/ActivAgentApplication/DirectoryService.h
T
2023-12-15 13:15:08 -05:00

111 lines
3.9 KiB
C++

/**
* @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 &sectionIterator);
bool m_shouldEnablePubSubMulticast; ///< Default: true. Whether pub-sub over multicast is enabled.
std::vector<String> m_pubSubMulticastAddressList; ///< Default: 233.58.54.255. Comma separated list of pub-sub multicast addresses.
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<uint16_t> 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<String> 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<String> m_hostConversionAttributeKeyList; ///< List of attribute keys that might contain hostnames that need converting to ip addresses for remote directories.
std::vector<String> 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<DirectoryService::Impl> MakeImpl(DirectoryService &directoryService,
const String &serviceName, const Settings &settings, const String &serviceLocationIniFile);
CxxYZ::unique_ptr<Impl> m_pImpl;
};
} // namespace Activ
#endif // (!defined ACTIV_AGENT_APPLICATION_DIRECTORY_SERVICE_H)