Documentation:Doc Outils PFCXX User Tata cc

From Gameforge Official Website

Jump to: navigation, search
/**
 * Generated by pfcxx
 * File : /tmp/src2/Tata.cc
 * Date : 2006-09-18 17:47:18.375297
 */
 
#ifdef HAVE_CONFIG_H
# include "config-server.h"
#endif
 
#include <iostream>
#include <string>
 
#include <ace/Guard_T.h>
 
#include <gameforge/server/pfcxx/drivers/Row.hh>
#include <gameforge/server/pfcxx/tools/DbConnectorPool.hh>
#include <gameforge/server/pfcxx/tools/Cache.hh>
#include <gameforge/server/pfcxx/query/Select.hh>
#include <gameforge/server/pfcxx/query/Insert.hh>
#include <gameforge/server/pfcxx/query/Create.hh>
#include <gameforge/server/pfcxx/query/Update.hh>
#include <gameforge/server/pfcxx/query/Delete.hh>
 
#include "include2/Tata.hh"
 
 
using namespace ::std;
using namespace ::hh::jj::kkkk;
using namespace ::gameforge::server::pfcxx;
using namespace ::gameforge::server::pfcxx::drivers;
using namespace ::gameforge::server::pfcxx::tools;
using namespace ::gameforge::server::pfcxx::query;
using namespace ::gameforge::server::pfcxx::persistence;
 
Tata::ptr Tata::newInstance(RowPtr row /*= RowPtr()*/ )
{
  Tata::ptr p;
 
  if(row.use_count() == 0)
  {
    p.reset(new Tata);
  }
  else
  {
    p.reset(new Tata(row));
  }
 
  p -> mThis = p;
  
  p -> id.setContainerTable(p);
  p -> yuyu.setContainerTable(p);
  p -> hhh.setContainerTable(p);
  
  return p;
}
 
Tata::~Tata(void)
{
}
 
void Tata::update(DbConnectorPtr db /*= DbConnectorPtr()*/ )
{
  ACE_Guard<ACE_Thread_Mutex> g(mMutex);
  
  DbConnectorPtr conn = getConnector(db);
 
  if(mIsNew)
  {
    Insert<Tata> query(conn);
 
    query.value<1>( this -> yuyu.value());
 
    vector<int32_t> seq = query.execute();
 
    this -> id = seq[0];
 
    mIsNew = false;
    assert(conn -> getCache() -> attach<Tata>(mThis.lock(), true));
  }
  else if(mDirty)
  {
    Update<Tata> query(conn);
 
    query.where<TableInfo<Tata>::pk>(Equals, (this->*ColumnInfo<Tata, TableInfo<Tata>::pk>::field).value());
    
    if(this -> id . isDirty())
    {
      query.value <0>(this -> id .value());
    }
    
    if(this -> yuyu . isDirty())
    {
      query.value <1>(this -> yuyu .value());
    }
 
    assert(query.execute() == 1);
  }
 
  resetDirty_();
}
 
void Tata::merge_(const Row &r, bool flag)
{
  if(flag || ! this -> id.isDirty()) this -> id = r.get<int32_t>(0);
  if(flag || ! this -> yuyu.isDirty()) this -> yuyu = r.get<std::string>(1);
}
 
void Tata::resetDirty_(void)
{
  this -> id.resetDirty();
  this -> yuyu.resetDirty();
 
  mDirty = false;
}
 
Tata::Tata(void) : 
  PersistenceObjectTmpl<Tata>(true)
{
}
 
std::string Tata::dump(void) const
{
  ACE_Guard<ACE_Thread_Mutex> g(mMutex);
  
  ostringstream d;
 
  d << "hh::jj::kkkk::Tata (" << hex << this << dec << ") :";
  d << " " << this -> id.dump();
  d << " " << this -> yuyu.dump();
 
  return d.str();
}
 
Tata::Tata(RowPtr row) :
  PersistenceObjectTmpl<Tata>(false),
  id(row -> get<int32_t>(0)),
  yuyu(row -> get<std::string>(1))
{
}
template <> void Tata::dirty<0>(void)
{
  hhh.reset();
 
  mDirty = true;
}
Personal tools