61 lines
1.2 KiB
C++
61 lines
1.2 KiB
C++
#include "SecurityIndex.h"
|
|
|
|
#include "lib/md/HandleIndex.h"
|
|
|
|
|
|
namespace bts {
|
|
namespace fix {
|
|
|
|
struct SecurityIndex::PImpl
|
|
{
|
|
md::DescHandleIndex index;
|
|
md::KeyHandleIndex key_index;
|
|
PImpl(md::MDClient& md) : index(md), key_index(md)
|
|
{
|
|
}
|
|
};
|
|
|
|
|
|
SecurityIndex::SecurityIndex(md::MDClient& md) : me(new PImpl(md))
|
|
{
|
|
}
|
|
|
|
std::vector<md::SecurityPtr> SecurityIndex::get_securities()
|
|
{
|
|
std::vector<md::SecurityPtr> list;
|
|
me->index.security_index.lock([&list] (const auto& secmap)
|
|
{
|
|
for(const auto& s : secmap)
|
|
list.push_back(s.second);
|
|
});
|
|
return list;
|
|
}
|
|
|
|
|
|
md::SecurityPtr SecurityIndex::lookup(const std::string& desc)
|
|
{
|
|
md::SecurityPtr ptr = nullptr;
|
|
me->index.security_index.lock([&ptr, &desc] (const auto& secmap)
|
|
{
|
|
auto it = secmap.find(desc);
|
|
if(it != secmap.end())
|
|
ptr = it->second;
|
|
});
|
|
return ptr;
|
|
}
|
|
|
|
md::SecurityPtr SecurityIndex::lookup(md::security_key key)
|
|
{
|
|
md::SecurityPtr ptr = nullptr;
|
|
me->key_index.security_index.lock([&ptr, &key] (const auto& secmap)
|
|
{
|
|
auto it = secmap.find( SecurityKey(key) );
|
|
if(it != secmap.end())
|
|
ptr = it->second;
|
|
});
|
|
return ptr;
|
|
}
|
|
|
|
}}
|
|
|
|
|