Prevent raw FixedSecurity from being created unintentionally
This commit is contained in:
1 parent
2db2af67a0
commit
58be751faa
1 file changed
+12
-3
@@ -19,12 +19,15 @@ GCC_DIAG_OFF("-Weffc++") // No Virtual Destructors by design
|
||||
void NAME(const char* val, size_t size) { strncpy(_##NAME, val, std::min(BTS_ARRAYSIZE(_##NAME)-1, size)); _##NAME[std::min(BTS_ARRAYSIZE(_##NAME)-1, size)] = '\0'; } \
|
||||
void NAME(const std::string& val) { NAME(val.c_str(), val.size()); }
|
||||
|
||||
struct ColdEntry;
|
||||
// Caution: FixedSecurity is a variable sized structure
|
||||
// Use FixedSecurity::size to determine size not sizeof()
|
||||
class BTS_EXPORT FixedSecurity
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
FixedSecurity();
|
||||
friend ColdEntry;
|
||||
public:
|
||||
FixedSecurity(const FixedSecurity&) = delete;
|
||||
~FixedSecurity();
|
||||
|
||||
@@ -59,6 +62,13 @@ private:
|
||||
char _platform_id[64];
|
||||
};
|
||||
|
||||
class FixedStockSecurity : public FixedSecurity {
|
||||
public:
|
||||
FixedStockSecurity() {
|
||||
type = api::SECURITYTYPE_STOCK;
|
||||
};
|
||||
};
|
||||
|
||||
class BTS_EXPORT FixedFutureSecurity : public FixedSecurity
|
||||
{
|
||||
public:
|
||||
@@ -174,8 +184,7 @@ template <class C>
|
||||
void with_security(SecurityType type, size_t leg_count, const api::Security* psynthetic, C cb) {
|
||||
switch(type) {
|
||||
case api::SECURITYTYPE_STOCK: {
|
||||
FixedSecurity security;
|
||||
security.type = api::SECURITYTYPE_STOCK;
|
||||
FixedStockSecurity security;
|
||||
cb(security);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user