#ifndef GMAC_INCLUDE_GMAC_COMMAND_H_ #define GMAC_INCLUDE_GMAC_COMMAND_H_ #include "gmac_info.h" #include "gmac.h" #include #ifdef __cplusplus extern "C" { #endif typedef enum { GMAC_COMMAND_INVALID, GMAC_COMMAND_SWITCH, ///< GMAC Activate (switch on or off) an object. GMAC_COMMAND_REFRESH, ///< General refresh GMAC_COMMAND_REFRESH_STOP, ///< General refresh stop GMAC_COMMAND_FILTER_SWITCH, ///< Activate Filtering GMAC_COMMAND_FILTER_ADD, GMAC_COMMAND_MAX } GMACCommandType; typedef struct { GMACCommandType Type; const char* Description; } GMACCommandTypeDesc_t; static const GMACCommandTypeDesc_t GMACCommandTypeDesc [] GMAC_UNUSED = { { GMAC_COMMAND_INVALID, "INVALID" }, { GMAC_COMMAND_SWITCH, "SWITCH" }, { GMAC_COMMAND_REFRESH, "REFRESH" }, { GMAC_COMMAND_REFRESH_STOP, "REFRESH_STOP" }, { GMAC_COMMAND_FILTER_SWITCH, "FILTER_SWITCH" }, { GMAC_COMMAND_FILTER_ADD, "FILTER_ADD" }, { GMAC_COMMAND_MAX, "MAX" } }; const char* GMACCommandTypeToString(GMACCommandType type); /** * \ingroup GMAC_UserAPI * \brief A command structure to pass to gmac */ typedef struct { GMACCommandType commandType; ///< The command to execute GMACObjType objType; ///< The receiving object type GMACObjID objID; ///< The receiving object id size_t commandParamSize; ///< The command parameter structure's size char commandParams[]; ///< pointer to the start of the command parameters } GMACCommandStruct; /** * \ingroup GMAC_UserAPI * \brief An activation parameters */ typedef struct { bool Activate; ///< True activate object ( SrcChannel, DstChannel, Market, Queue ) } GMACSwitchParam; typedef enum { GMAC_REFRESH_SUBJECT_TYPE_DICT, ///< Request instrument description (dictionary) GMAC_REFRESH_SUBJECT_TYPE_INST, ///< Request instrument data such book, trade ,stats. it depends on the market GMAC_REFRESH_SUBJECT_TYPE_BOOK, GMAC_REFRESH_SUBJECT_TYPE_STATUS, GMAC_REFRESH_SUBJECT_TYPE_TRADE, GMAC_REFRESH_SUBJECT_TYPE_STATS, GMAC_REFRESH_SUBJECT_TYPE_AUCTION, GMAC_REFRESH_SUBJECT_TYPE_ANNOUNCE, GMAC_REFRESH_SUBJECT_TYPE_CHANNEL, ///< Activate / Disable Channel equivalant to GMAC_COMMAND_SWITCH } GMACRefreshSubjectType_t; typedef struct { GMACRefreshSubjectType_t Type; const char* Description; } GMACRefreshSubjectTypeDesc_t; static const GMACRefreshSubjectTypeDesc_t GMACRefreshSubjectTypeDesc [] GMAC_UNUSED = { { GMAC_REFRESH_SUBJECT_TYPE_DICT, "DICT" }, { GMAC_REFRESH_SUBJECT_TYPE_INST, "INST" }, { GMAC_REFRESH_SUBJECT_TYPE_BOOK, "BOOK" }, { GMAC_REFRESH_SUBJECT_TYPE_STATUS, "STATUS" }, { GMAC_REFRESH_SUBJECT_TYPE_TRADE, "TRADE" }, { GMAC_REFRESH_SUBJECT_TYPE_STATS, "STATS" }, { GMAC_REFRESH_SUBJECT_TYPE_AUCTION, "AUCTION" }, { GMAC_REFRESH_SUBJECT_TYPE_ANNOUNCE, "ANNOUNCE" }, { GMAC_REFRESH_SUBJECT_TYPE_CHANNEL, "CHANNEL" } }; const char* GMACRefreshSubjectToString(GMACRefreshSubjectType_t); typedef struct { union { struct { unsigned RefreshSubject:1; unsigned RefreshSubjectU64:1; unsigned RefreshSubjectU32:1; unsigned RefreshSubjectU16:1; unsigned RefreshSubjectU8:1; unsigned RefreshContext:1; unsigned RefreshDataType:1; unsigned RefreshCustomerID:1; } PresenceMap; uint32_t PresenceMapAll; }; GMACRefreshSubjectType_t RefreshSubjectType; ///< Market Custom Refresh type union { char RefreshSubject[32]; ///< Custom buffer of market refresh. uint64_t RefreshSubjectU64; uint32_t RefreshSubjectU32; uint16_t RefreshSubjectU16; uint8_t RefreshSubjectU8; }; uint64_t RefreshContext; ///< Sequence number or time stamp from where the refresh char RefreshDataType; ///< The type of return data uint64_t RefreshCustomerID; } GMACRefreshParam; typedef struct { union { struct { unsigned Symbol:1; unsigned SymbolU64:1; unsigned SymbolU32:1; unsigned SymbolU16:1; unsigned SymbolU8:1; } PresenceMap; uint32_t PresenceMapAll; }; union { char Symbol[32]; uint64_t SymbolU64; uint32_t SymbolU32; uint16_t SymbolU16; uint8_t SymbolU8; }; } GMACFilterAddParam; /** * \ingroup GMAC_UserAPI * \brief Helper macro to declare on stack a GMACCommandStruct * @param name the name of the declared variable pointer * @param CommandParam the additional command parameters type */ #define GMAC_DECLARE_COMMNAND_STRUCT(name, CommandParam) \ char name##buf[sizeof(GMACCommandStruct) + sizeof(CommandParam)]; \ GMACCommandStruct* name = (GMACCommandStruct*)name##buf; \ name->commandParamSize = sizeof(CommandParam); /** * * \ingroup GMAC_UserAPI * \brief Function to control gmac * @param GMACH GMAC Handle * @param commandStruct a structure that determine what you need to command. * @return GMAC_STATUS_OK or GMAC_STATUS_PARAM_ERROR if invalid Channel ID/MulticastType supplied */ extern GMACStatus GMACCommand(GMACHandle* handle, const GMACCommandStruct* commandStruct); #ifdef __cplusplus } #endif #endif /* GMAC_INCLUDE_GMAC_COMMAND_H_ */