Re: [Quickfix-developers] Privately defined messages
Brought to you by:
orenmnero
|
From: <OM...@th...> - 2003-02-04 16:00:40
|
First, one point. Your messages can be in whatever namespace you like,
however you will likely want to inherit from the FIX42::Message class.
Basically if you wanted to put that message in another namespace, like FIX
or something else, it would look like this:
namespace FIX
{
class UsrMessage1 : public FIX42::Message
{
...
}
}
This does a couple things for you. First it will set the BeginString in
the header to FIX.4.2 for you, and second it will supply your message with
a typesafe FIX4.2 header. You don't strictly *need* this (you can set the
beginstring in the constructor or manually in your code if you like),
however this is the best way.
What you have here looks reasonable. In fact very similar to what QF would
be using for standard messages (except the if/else statement is
encapsulated in the MessageCrackers). You can perhaps even use the QF
code generation (see spec\generate_c++.bat) to do much of this work for
you. In the future I hope to set up the code generation so it is more
friendly for creating user defined standards. That way you just create an
XML file and the rest is taken care of for you.
--oren
|---------+----------------------------------------------->
| | "Hugo Leote" |
| | <Hug...@in...> |
| | Sent by: |
| | qui...@li...|
| | ceforge.net |
| | |
| | |
| | 02/04/2003 08:31 AM |
| | |
|---------+----------------------------------------------->
>----------------------------------------------------------------------------------------------|
| |
| To: qui...@li... |
| cc: |
| Subject: [Quickfix-developers] Privately defined messages |
>----------------------------------------------------------------------------------------------|
Hi,
I had to define some private (user defined) messages that have been
agreeed by both firms. After a bit of work, I got something that works.
However, I wonder if there is a cleaner way to do this.
The code follows.
Somewhere in "myfields.h":
(...)
namespace FIX
{
USER_DEFINE_STRING(UsrField1, 5000);
USER_DEFINE_STRING(UsrFiled2, 5001);
}
(...)
Somewhere in "mymessages.h":
(...)
namespace FIX
{
const char MsgType_UsrMessage1[] = "U1";
}
namespace FIX42
{
// Had to do this in FIX42 namespace.
// User messages defined inside the FIX namespace
// always cause an automatic "reject" on
receiving,
// thereby never reaching crack().
class UsrMessage1 : public Message
{
public:
UsrMessage1() : Message( MsgType() ) {}
UsrMessage1 ( const Message& m ) : Message( m ) {}
static FIX::MsgType MsgType() { return
FIX::MsgType(
FIX::MsgType_UsrMessage1 ); }
FIELD_SET( *this, FIX::UsrField1 );
FIELD_SET( *this, FIX::UsrField2 );
};
}
(...)
Somewhere in "myfixapplication.cpp" :
(...)
// Receive user message
void CFixApplication::onMessage (const FIX42::Message&
message,
const
FIX::SessionID& sessionID)
{
// Ugly. Had to create this "catch
all" to handle
the user defined messages
// Maybe there's a
cleaner/prettier/better way to
do this...
FIX::MsgType msgType;
message.getHeader().getField( msgType );
if (msgType == FIX::MsgType_UsrMessage1)
onMessage((FIX42::UsrMessage1)message,
sessionID);
else
throw FIX::UnsupportedMessageType();
}
void CFixApplication::onMessage (const FIX42::UsrMessage1&
message,
const
FIX::SessionID& sessionID)
{
// TODO: Proper handling of this message...
AfxMessageBox ("Got proprietary message
UsrMessage1 !");
}
(...)
Thanks in advance,
Hugo Leote
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Quickfix-developers mailing list
Qui...@li...
https://lists.sourceforge.net/lists/listinfo/quickfix-developers
|