115 lines
3.6 KiB
C++
115 lines
3.6 KiB
C++
/*
|
|
* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
|
|
*
|
|
* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
|
|
* and international copyright treaties.
|
|
*
|
|
* Access to and use of the software is governed by the terms of the applicable OnixS Software
|
|
* Services Agreement (the Agreement) and Customer end user license agreements granting
|
|
* a non-assignable, non-transferable and non-exclusive license to use the software
|
|
* for it's own data processing purposes under the terms defined in the Agreement.
|
|
*
|
|
* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
|
|
* of this source code or associated reference material to any other location for further reproduction
|
|
* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
|
|
*
|
|
* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
|
|
* the terms of the Agreement is a violation of copyright law.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <OnixS/FIXEngine/ABI.h>
|
|
|
|
#include <string>
|
|
#include <stdint.h>
|
|
|
|
namespace OnixS {
|
|
namespace FIX {
|
|
namespace TCPDirect {
|
|
|
|
/**
|
|
* TCPDirect attributes to pass configuration details (a wrapper around the zf_Attributes struct).
|
|
*
|
|
* The default values for attributes may be overridden by setting the
|
|
* environment variable ZF_Attributes. For example:
|
|
*
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.sh}
|
|
* ZF_Attributes="interface=enp4s0f0;log_level=3;reactor_spin_count=1"
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
*/
|
|
class ONIXS_FIXENGINE_API Attributes
|
|
{
|
|
public:
|
|
/** Allocate an attribute object.
|
|
*
|
|
* \throws The std::bad_alloc is thrown if the memory could not be allocated.
|
|
* \throws The std::runtime_error if the ZF_Attributes environment variable is malformed.
|
|
*/
|
|
Attributes();
|
|
|
|
~Attributes();
|
|
|
|
Attributes(const Attributes& other);
|
|
|
|
Attributes& operator=(const Attributes& other);
|
|
|
|
/// Sets the network interface name.
|
|
void networkInterface(const std::string& ifName)
|
|
{
|
|
set("interface", ifName);
|
|
}
|
|
|
|
/**
|
|
* Gets the attribute value.
|
|
*
|
|
* \param name The name of the attribute.
|
|
*
|
|
* \throws The std::logic_error is thrown if the @p name is not a valid attribute name
|
|
* or if the @p name does not have a string type.
|
|
*/
|
|
std::string getString(const std::string& name);
|
|
|
|
/**
|
|
* Sets an attribute to a string value.
|
|
*
|
|
* \param name The name of the attribute.
|
|
* \param value The new value for the attribute.
|
|
*
|
|
* \throws The std::logic_error is thrown if the @p name is not a valid attribute name
|
|
* or if the attribute is not a string attribute.
|
|
*/
|
|
void set(const std::string& name, const std::string& value);
|
|
|
|
/**
|
|
* Gets the attribute value.
|
|
*
|
|
* \param name The name of the attribute.
|
|
*
|
|
* \throws The std::logic_error is thrown if the @p name is not a valid attribute name
|
|
* or if the @p name does not have an integer type.
|
|
*/
|
|
int64_t getInt(const std::string& name);
|
|
|
|
/**
|
|
* Sets an attribute to an integer value.
|
|
*
|
|
* \param name The name of the attribute.
|
|
* \param value The new value for the attribute.
|
|
*
|
|
* \throws The std::logic_error is thrown if the @p name is not a valid attribute name.
|
|
* \throws The std::domain_error is thrown if the @p value is not within the range of values this
|
|
* attribute can take.
|
|
*/
|
|
void set(const std::string& name, uint64_t value);
|
|
|
|
private:
|
|
class Impl;
|
|
Impl* const impl_;
|
|
|
|
friend class Stack;
|
|
};
|
|
|
|
}
|
|
}
|
|
}
|