11 #include "error_codes.h"
43 virtual void read(std::istream& str) = 0;
46 virtual void write(std::ostream& str)
const = 0;
73 virtual std::string header(
void)
const = 0;
75 void read_binary(std::istream& str) {};
76 void write_binary(std::ostream& str)
const {};
79 Data(std::vector <std::string> &){};
81 virtual const std::string get_file_name()
const {
return this->
file_name;};
82 virtual const std::string get_table_name()
const {
return this->
table_name;};
84 virtual const bool indexed()
const {
return false;};
86 virtual const bool get_binary()
const {
return this->
binary;};
96 virtual const std::string
sql_header(
void)
const {
return "";};
104 virtual const std::string
sql_values(
void)
const {
return "";};
108 virtual void sql_read(std::istream &);
127 virtual size_t size(
void)
const {
return 0;};
133 static Data *
new_from_str (
const std::string &,
const std::vector<std::string> &);
148 using Data::write_binary;
149 using Data::read_binary;
150 void write_pos(std::ostream& str)
const
152 str.write((
char *)(&abs_pos_),
sizeof(id1_t) );
155 void read_pos(std::istream& str)
157 str.read((
char *)(&abs_pos_),
sizeof(id1_t) );
165 const bool indexed()
const {
return true;};
173 #define get_abs_pos1 get_abs_pos
174 #define set_abs_pos1 set_abs_pos
179 id1_t abs_pos1_, abs_pos2_;
181 using Data::write_binary;
182 using Data::read_binary;
184 void write_pos(std::ostream& str)
const
186 str.write((
char *)(&abs_pos1_),
sizeof(id1_t) );
187 str.write((
char *)(&abs_pos2_),
sizeof(id1_t) );
190 void read_pos(std::istream& str)
192 str.read((
char *)(&abs_pos1_),
sizeof(id1_t) );
193 str.read((
char *)(&abs_pos2_),
sizeof(id1_t) );
205 const bool indexed()
const {
return true;};
212 static struct Registry_initalizer {
213 Registry_initalizer ();
214 ~Registry_initalizer ();
215 } Registry_initalizer;
226 Registration (
const std::string &str,
Data*(*fn)(
const std::vector <std::string> &) );
233 std::vector <std::string> registry_list(
void);
Registration(const std::string &str, Data *(*fn)(const std::vector< std::string > &))
< The constructor of Registration, which stores a constructor for a Data class to new_data_ ...
Definition: data.cc:72
virtual void write(std::ostream &str) const =0
The write function must be defined in the child class.
static Data * new_from_str(const std::string &, const std::vector< std::string > &)
Constructs an instance of the class Registered w/ string.
Definition: data.cc:37
static const bool binary
A flag to indicate that binary reading/writing is not supported by default.
Definition: data.h:39
Data which has an absolute position.
Definition: data.h:144
friend std::istream & operator>>(std::istream &, Data &)
Use the >> operator to read Data in text mode.
Definition: data.cc:60
virtual const std::string sql_values(void) const
Return the values to be placed in columns.
Definition: data.h:104
void set_abs_pos(const id1_t &)
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:143
friend std::ostream & operator<<(std::ostream &, const Data &)
Use the << operator to write Data in text mode.
Definition: data.cc:66
virtual const std::string sql_header(void) const
Return the names of the columns, along with variable type.
Definition: data.h:96
void set_abs_pos(const id1_t &)
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:138
id1_t get_abs_pos(void) const
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:128
static const std::string file_name
The read function must be defined in the child class.
Definition: data.h:69
virtual void sql_read(std::istream &)
Reads the values...
Definition: data.cc:53
virtual void read(std::istream &str)=0
The read function must be defined in the child class.
void set_abs_pos2(const id1_t &)
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:148
id1_t get_abs_pos(void) const
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:123
A class which registers a child of Data in Data::new_data_.
Definition: data.h:222
A class which can be written as flat text file or into an SQL database.
Definition: data.h:34
virtual const std::string sql_column_names(void) const
Return the names of the columns.
Definition: data.h:100
id1_t get_abs_pos2(void) const
Indexed data needs to associate each datum with a position in the genome.
Definition: data.cc:133
static const std::string table_name
The read function must be defined in the child class.
Definition: data.h:71
virtual size_t size(void) const
The size of the class in bytes.
Definition: data.h:127