2018-03-26 20:39:10 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
2018-03-29 15:06:20 +00:00
|
|
|
#include <typeinfo>
|
2018-03-26 20:39:10 +00:00
|
|
|
#include "../util/Serializable.h"
|
|
|
|
|
|
|
|
namespace ki
|
|
|
|
{
|
|
|
|
namespace dml
|
|
|
|
{
|
|
|
|
class Record;
|
|
|
|
|
|
|
|
class FieldBase : public util::Serializable
|
|
|
|
{
|
|
|
|
friend Record;
|
|
|
|
public:
|
2018-03-29 15:06:20 +00:00
|
|
|
virtual ~FieldBase() = default;
|
|
|
|
|
2018-03-26 20:39:10 +00:00
|
|
|
const Record &get_record() const;
|
|
|
|
std::string get_name() const;
|
|
|
|
bool is_transferable() const;
|
|
|
|
|
|
|
|
template <typename ValueT>
|
|
|
|
bool is_type() const
|
|
|
|
{
|
|
|
|
return (typeid(ValueT).hash_code() == m_type_hash);
|
|
|
|
}
|
|
|
|
protected:
|
2018-03-29 15:06:20 +00:00
|
|
|
std::string m_name;
|
|
|
|
bool m_transferable;
|
2018-03-26 20:39:10 +00:00
|
|
|
size_t m_type_hash;
|
|
|
|
|
|
|
|
FieldBase(std::string name, const Record& record);
|
|
|
|
|
|
|
|
virtual FieldBase *clone(const Record &record) const = 0;
|
|
|
|
private:
|
|
|
|
const Record &m_record;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<FieldBase *> FieldList;
|
|
|
|
typedef std::map<std::string, FieldBase *> FieldNameMap;
|
|
|
|
}
|
|
|
|
}
|