Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// rtrsd_servicefindermultiplexer.h -*-C++-*-
#ifndef INCLUDED_RTRSD_SERVICEFINDERMULTIPLEXER
#define INCLUDED_RTRSD_SERVICEFINDERMULTIPLEXER
#include <rtrsd_servicefinderi.h>
#include <rtrsd_servicemajor.h>
#include <rtrsd_serviceregistry.h>
#include <bslma_managedptr.h>
#include <bsls_annotation.h>
#include <bsls_keyword.h>
#include <bsl_functional.h>
#include <bsl_unordered_set.h>
#include <bsl_vector.h>
//@PURPOSE: TODO
//
//@CLASSES:
// ServiceFinderMultiplexer: TODO
//
//@DESCRIPTION: TODO
namespace BloombergLP {
namespace rtrsd { class ServiceMajor; }
namespace rtrsd { class Endpoint; }
namespace rtrsd {
// ==============================
// class ServiceFinderMultiplexer
// ==============================
class ServiceFinderMultiplexer : public ServiceFinderFactoryI {
private:
// PRIVATE TYPES
class SFMServiceFinder : public ServiceFinderI {
ServiceFinderMultiplexer& d_sfm;
SFMServiceFinder(ServiceFinderMultiplexer& sfm)
: d_sfm(sfm)
{
d_sfm.registerFinder(this);
}
SFMServiceFinder(const SFMServiceFinder&); //= delete;
~SFMServiceFinder() { d_sfm.unregisterFinder(this); }
void setOnUpdateCallback(
const UpdateCb& onUpdateCallback) BSLS_KEYWORD_OVERRIDE
{
d_sfm.setCallbackFor(this, onUpdateCallback);
}
// TODO
BSLS_ANNOTATION_WARN_UNUSED_RESULT
int subscribe(const bsl::vector<ServiceMajor>& services,
const UpdateCb& subscriptionAcknowledgedCallback)
BSLS_KEYWORD_OVERRIDE
{
d_sfm.subscribe(...);
}
// TODO
BSLS_ANNOTATION_WARN_UNUSED_RESULT
int unsubscribe(
const bsl::vector<ServiceMajor>& services) BSLS_KEYWORD_OVERRIDE
{
d_sfm.unsubscribe(...);
}
// TODO
};
// DATA
ServiceFinderI& d_underlying;
bsl::unordered_map<SFMServiceFinder *, ServiceFinderI::UpdateCb>
d_callbacks;
// PRIVATE MANIPULATORS
BSLS_ANNOTATION_WARN_UNUSED_RESULT
int subscribe(
const bsl::vector<ServiceMajor>& services,
const UpdateCb& subscriptionAcknowledgedCallback)
{
d_underlying.subscribe(...);
}
BSLS_ANNOTATION_WARN_UNUSED_RESULT
int unsubscribe(const bsl::vector<ServiceMajor>& services)
{
d_underlying.unsubscribe(...);
}
public:
ServiceFinderMultiplexer(ServiceFinderI& underlying)
: d_underlying(underlying)
{
d_underlying.setOnUpdateCallback(somethingInternal);
}
// MANIPULATORS
BSLS_ANNOTATION_WARN_UNUSED_RESULT
bslma::ManagedPtr<ServiceFinderI> create(
bslma::Allocator *basicAllocator = 0) BSLS_KEYWORD_OVERRIDE
{
return bslma::ManagedPtr<ServiceFinderI>(new SFMServiceFinder(*this));
}
// TODO
};
} // close package namespace
} // close enterprise namespace
#endif
// ----------------------------------------------------------------------------
// NOTICE:
// Copyright (C) Bloomberg L.P., 2018
// All Rights Reserved.
// Property of Bloomberg L.P. (BLP)
// This software is made available solely pursuant to the
// terms of a BLP license agreement which governs its use.
// ----------------------------- END-OF-FILE ----------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.