class CMarket : public Dapfor::Common::CDataObject
{
public:
enum
{
FidMarketName = 100,
FidMarketState,
};
enum MarketState
{
Connected,
Disconnected,
};
public:
CMarket(const std::string& name, MarketState state);
virtual ~CMarket();
std::string GetMarketName() const;
long GetMarketState() const;
private:
MarketState m_MarketState;
std::string m_Name;
DF_DECLARE_FIELD_MAP();
};
Dapfor::Common::CLongEnumFormat::Item states[] =
{
{CMarket::Connected, "Connected"},
{CMarket::Disconnected, "Disconnected"},
};
DF_BEGIN_FIELD_MAP(CMarket)
DF_STL_STRING_ID(FidMarketName, "Market", &CMarket::GetMarketName, 0, 0)
DF_LONG_ID (FidMarketState, "State", &CMarket::GetMarketState, 0, DF_ENUM_FORMAT(states))
DF_END_FIELD_MAP()
CMarket::CMarket(const std::string& name, MarketState state) : m_Name(name),
m_MarketState(state)
{
}
CMarket::~CMarket()
{
NotifyDelete();
}
std::string CMarket::GetMarketName() const
{
return m_Name;
}
long CMarket::GetMarketState() const
{
return m_MarketState;
}
class CInstrument : public Dapfor::Common::CDelegate
{
public:
enum
{
FidInstrumentName = 200,
};
public:
CInstrument(const std::string& name, CMarket* market);
virtual ~CInstrument();
std::string GetInstrumentName() const;
private:
std::string m_Name;
DF_DECLARE_FIELD_MAP();
};
DF_BEGIN_FIELD_MAP(CInstrument)
DF_STL_STRING_ID(FidInstrumentName, "Instrument", &CInstrument::GetInstrumentName, 0, 0)
DF_END_FIELD_MAP()
CInstrument::CInstrument(const std::string& name, CMarket* market)
: Dapfor::Common::CDelegate(market, false)
, m_Name(name)
{
}
CInstrument::~CInstrument()
{
NotifyDelete();
}
std::string CInstrument::GetInstrumentName() const
{
return m_Name;
}
...
Dapfor::GUI::CHeader* header = new Dapfor::GUI::CHeader();
header->Add(new Dapfor::GUI::CColumn(CMarket::FidMarketName, "Market", 100));
header->Add(new Dapfor::GUI::CColumn(CMarket::FidMarketState, "State", 100));
header->Add(new Dapfor::GUI::CColumn(CInstrument::FidInstrumentName, "Instrument", 100));
m_Grid.SetHeader(header);
...
...
CMarket* market = new CMarket("Bloomberg", CMarket::Connected);
CInstrument* instrument = new CInstrument("Bond", market);
m_Grid.Add(instrument);