Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/flucoma/clients/common/FluidBaseClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ under the European Union’s Horizon 2020 research and innovation programme
#include "TupleUtilities.hpp"
#include "../../data/FluidIndex.hpp"
#include "../../data/FluidMeta.hpp"
#include <string>
#include <string_view>
#include <tuple>

namespace fluid {
Expand All @@ -29,6 +31,18 @@ namespace client {
struct ModelObject
{};

// Mixin for shared clients that want to know the name they are registered
// under (e.g. for printing). The name is not a parameter: it is owned by
// NRTSharedInstanceAdaptor, which keeps this copy up to date.
struct NamedObject
{
void setName(std::string_view name) { mName = name; }
const std::string& name() const { return mName; }

private:
std::string mName;
};

enum ProcessState { kNoProcess, kProcessing, kDone, kDoneStillProcessing };

struct ControlChannel {
Expand Down
3 changes: 3 additions & 0 deletions include/flucoma/clients/common/MessageSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ class MessageSet<std::tuple<Ts...>>
return std::get<N>(mMessages)(std::forward<Us>(us)...);
}

/// The underlying tuple of messages, e.g. for concatenating sets
const MessagesType& messages() const noexcept { return mMessages; }

private:
MessagesType mMessages;

Expand Down
10 changes: 5 additions & 5 deletions include/flucoma/clients/nrt/CorpusClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ namespace fluid {
namespace client {
namespace corpus {

enum { kName };

constexpr auto CorpusParams =
defineParameters(StringParam<Fixed<true>>("name", "Corpus name"));
defineParameters();

class CorpusClient : public FluidBaseClient, public OfflineIn, public OfflineOut
class CorpusClient : public FluidBaseClient,
public OfflineIn,
public OfflineOut,
public NamedObject
{
using string = std::string;
using Buffer = typename BufferT::type;
Expand Down Expand Up @@ -72,8 +74,6 @@ class CorpusClient : public FluidBaseClient, public OfflineIn, public OfflineOut
return {};
}

std::string name() const { return get<kName>(); }

MessageResult<void> addPoint(string label, Buffer buffer, size_t offset,
int length)
{
Expand Down
1 change: 0 additions & 1 deletion include/flucoma/clients/nrt/DataClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class DataClient
return OK();
}


MessageResult<void> write(string fileName)
{
auto file = JSONFile(fileName, "w");
Expand Down
6 changes: 3 additions & 3 deletions include/flucoma/clients/nrt/DataSetClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ namespace fluid {
namespace client {
namespace dataset {

enum { kName };

constexpr auto DataSetParams =
defineParameters(StringParam<Fixed<true>>("name", "Name of the DataSet"));
defineParameters();

template <typename T, typename U>
double distance(FluidTensorView<T, 1> point1, FluidTensorView<U, 1> point2)
Expand Down Expand Up @@ -53,6 +52,7 @@ auto sortedDistances(FluidTensorView<T, 1> x, FluidTensorView<U, 2> Y,
class DataSetClient : public FluidBaseClient,
OfflineIn,
OfflineOut,
public NamedObject,
public DataClient<FluidDataSet<std::string, double, 1>>
{
public:
Expand Down Expand Up @@ -306,7 +306,7 @@ class DataSetClient : public FluidBaseClient,

MessageResult<string> print()
{
return "DataSet " + std::string(get<kName>()) + ": " + mAlgorithm.print();
return "DataSet " + name() + ": " + mAlgorithm.print();
}

const DataSet& getDataSet() const { return mAlgorithm; }
Expand Down
Loading
Loading