00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _DATABASE_TEST_OBJECT_H_
00038 #define _DATABASE_TEST_OBJECT_H_
00039
00040 #include "database_interface/db_class.h"
00041
00042 namespace database_interface {
00043
00045
00048 class DatabaseTestObject : public DBClass
00049 {
00050 public:
00051
00052 DBField<int> pk_field_;
00053
00054 DBField<double> double_field_;
00055 DBField<std::string> string_field_;
00056 DBField< std::vector<std::string> > tags_field_;
00057
00058 DBField< std::vector<char> > binary_field_;
00059
00060 DBField<int> foreign_field_;
00061
00063
00070 void initFields()
00071 {
00072
00073 primary_key_field_ = &pk_field_;
00074
00075 fields_.push_back(&double_field_);
00076 fields_.push_back(&string_field_);
00077 fields_.push_back(&tags_field_);
00078 fields_.push_back(&binary_field_);
00079 fields_.push_back(&foreign_field_);
00080
00081
00082 foreign_keys_.insert( std::pair<std::string, DBFieldBase*>("test_object_foreign", &pk_field_) );
00083
00084
00085 pk_field_.setSequenceName("pk_field_sequence");
00086 }
00087
00089
00094 void initPermissions()
00095 {
00096 setAllFieldsReadFromDatabase(true);
00097 setAllFieldsWriteToDatabase(true);
00098
00099
00100 pk_field_.setWriteToDatabase(false);
00101
00102 binary_field_.setReadFromDatabase(false);
00103 binary_field_.setWriteToDatabase(false);
00104 }
00105
00107
00110 DatabaseTestObject() :
00111 pk_field_(DBFieldBase::TEXT, this, "pk_field", "test_object", true),
00112 double_field_(DBFieldBase::TEXT, this, "double_field", "test_object", true),
00113 string_field_(DBFieldBase::TEXT, this, "string_field", "test_object", true),
00114 tags_field_(DBFieldBase::TEXT, this, "tags_field", "test_object", true),
00115 binary_field_(DBFieldBase::BINARY, this, "binary_field", "test_object", true),
00116 foreign_field_(DBFieldBase::TEXT, this, "foreign_field", "test_object_foreign", true)
00117
00118 {
00119 initFields();
00120 initPermissions();
00121 }
00122
00124
00127 DatabaseTestObject(const DatabaseTestObject *other) :
00128 pk_field_(this, &other->pk_field_),
00129 double_field_(this, &other->double_field_),
00130 string_field_(this, &other->string_field_),
00131 tags_field_(this, &other->tags_field_),
00132 binary_field_(this, &other->binary_field_),
00133 foreign_field_(this, &other->foreign_field_)
00134 {
00135 initFields();
00136
00137 }
00138
00139
00140 };
00141
00142 }
00143
00144 #endif