database_original_model.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2009, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Willow Garage nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 
00035 // Author(s): Matei Ciocarlie
00036 
00037 #ifndef _DATABASE_ORIGINAL_MODEL_H_
00038 #define _DATABASE_ORIGINAL_MODEL_H_
00039 
00040 #include <database_interface/db_class.h>
00041 
00042 namespace household_objects_database {
00043 
00045 
00048 class DatabaseOriginalModel : public database_interface::DBClass
00049 {
00050  private:
00051 
00052  public:
00053   //primary key
00054   database_interface::DBField<int> id_;
00055   //fields from the original_model table
00056   database_interface::DBField<std::string> model_;
00057   database_interface::DBField<std::string> maker_;
00058   database_interface::DBField< std::vector<std::string> > tags_;
00059   database_interface::DBField<std::string> source_;
00060   database_interface::DBField<std::string> description_;
00061   database_interface::DBField<std::string> barcode_;
00062   database_interface::DBField<std::string> acquisition_method_;
00063   database_interface::DBField<std::string> recognition_id_;
00064   database_interface::DBField<bool> concave_filled_;
00065 
00067 
00074   void initFields()
00075   {
00076     //set the primary key
00077     primary_key_field_ = &id_;
00078     //and the rest of the fields
00079     fields_.push_back(&model_);
00080     fields_.push_back(&maker_);
00081     fields_.push_back(&tags_);
00082     fields_.push_back(&source_);
00083     fields_.push_back(&description_);
00084     fields_.push_back(&barcode_);
00085     fields_.push_back(&acquisition_method_);
00086     fields_.push_back(&recognition_id_);
00087     fields_.push_back(&concave_filled_);
00088     
00089     //sequences
00090     id_.setSequenceName("unscaled_model_unscaled_model_id_seq");
00091   }
00092 
00094 
00099   void initPermissions()
00100   {
00101     //by default, most fields are not used, so they should not be read from or written to database
00102     //WARNING: do this AFTER inserting your data into the fields_ vector
00103     setAllFieldsReadFromDatabase(false);
00104     setAllFieldsWriteToDatabase(false);
00105     //the fields that are usually used:
00106     //primary key id_ only syncs from database; it has a sequence which is used by default on insertions
00107     id_.setReadFromDatabase(true);
00108     //others that only sync to instance (we don't save them by default, but we try to retrieve them)
00109     tags_.setReadFromDatabase(true);
00110     barcode_.setReadFromDatabase(true);
00111     //the rest sync both ways; we'll put here those that have a NOT NULL constraint in the database
00112     model_.setReadWrite(true);
00113     maker_.setReadWrite(true);
00114     source_.setReadWrite(true);
00115     acquisition_method_.setReadWrite(true);
00116   }
00117 
00119 
00122  DatabaseOriginalModel()  : 
00123     id_(database_interface::DBFieldBase::TEXT, this, "original_model_id", "original_model", true),
00124     model_(database_interface::DBFieldBase::TEXT, this, "original_model_model" ,"original_model", true),
00125     maker_(database_interface::DBFieldBase::TEXT, this, "original_model_maker", "original_model", true),
00126     tags_(database_interface::DBFieldBase::TEXT, this, "original_model_tags", "original_model", true),
00127     source_(database_interface::DBFieldBase::TEXT, this, "original_model_source", "original_model", true),
00128     description_(database_interface::DBFieldBase::TEXT, this, "original_model_description", "original_model", true),
00129     barcode_(database_interface::DBFieldBase::TEXT, this, "original_model_barcode", "original_model", true),
00130     acquisition_method_(database_interface::DBFieldBase::TEXT, this, "acquisition_method_name", "original_model", true),
00131     recognition_id_(database_interface::DBFieldBase::TEXT, this, "original_model_recognition_id", 
00132                     "original_model", true),
00133     concave_filled_(database_interface::DBFieldBase::TEXT, this, "original_model_concave_filled", 
00134                     "original_model", true)
00135   {
00136     initFields();
00137     initPermissions();
00138   }
00139 
00141 
00144  DatabaseOriginalModel(const DatabaseOriginalModel *other) : 
00145     id_(this, &other->id_),
00146     model_(this, &other->model_),
00147     maker_(this, &other->maker_),
00148     tags_(this, &other->tags_),
00149     source_(this, &other->source_),
00150     description_(this, &other->description_),
00151     barcode_(this, &other->barcode_),
00152     acquisition_method_(this, &other->acquisition_method_),
00153     recognition_id_(this, &other->recognition_id_),
00154     concave_filled_(this, &other->concave_filled_)
00155       {
00156         initFields();
00157         //no need to call initPermissions() since field permission are copied over from other
00158       }
00159 };
00160 
00161 } //namespace model_database
00162 
00163 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


household_objects_database
Author(s): Matei Ciocarlie, except for source files individually marked otherwise
autogenerated on Fri Jan 25 2013 15:02:09