Documentation:Doc Outils PFCXX User TotoTyty cc

From Gameforge Official Website

Jump to: navigation, search
/**
 * Generated by pfcxx
 * File : /tmp/src1/TotoTyty.cc
 * Date : 2006-09-18 17:47:18.372570
 */
 
#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 "include1/TotoTyty.hh"
 
#include "include2/Tata.hh"
 
using namespace ::std;
using namespace ::gt::hh::ppp;
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;
 
TotoTyty::ptr TotoTyty::newInstance(RowPtr row /*= RowPtr()*/ )
{
  TotoTyty::ptr p;
 
  if(row.use_count() == 0)
  {
    p.reset(new TotoTyty);
  }
  else
  {
    p.reset(new TotoTyty(row));
  }
 
  p -> mThis = p;
  
  p -> id.setContainerTable(p);
  p -> yuyu.setContainerTable(p);
  p -> pouet.setContainerTable(p);
  p -> fkid.setContainerTable(p);
  
	return p;
}
 
TotoTyty::~TotoTyty(void)
{
}
 
void TotoTyty::update(DbConnectorPtr db /*= DbConnectorPtr()*/ )
{
  ACE_Guard<ACE_Thread_Mutex> g(mMutex);
  
  DbConnectorPtr conn = getConnector(db);
 
  if(mIsNew)
  {
    Insert<TotoTyty> query(conn);
 
    query.value<1>( this -> yuyu.value());
    query.value<2>( this -> pouet.value());
    query.value<3>( this -> fkid.value());
 
    vector<int32_t> seq = query.execute();
 
    this -> id = seq[0];
 
    mIsNew = false;
    assert(conn -> getCache() -> attach<TotoTyty>(mThis.lock(), true));
  }
  else if(mDirty)
  {
    Update<TotoTyty> query(conn);
 
    query.where<TableInfo<TotoTyty>::pk>(Equals, (this->*ColumnInfo<TotoTyty, TableInfo<TotoTyty>::pk>::field).value());
    
    if(this -> id . isDirty())
    {
      query.value <0>(this -> id .value());
    }
    
    if(this -> yuyu . isDirty())
    {
      query.value <1>(this -> yuyu .value());
    }
    
    if(this -> pouet . isDirty())
    {
      query.value <2>(this -> pouet .value());
    }
    
    if(this -> fkid . isDirty())
    {
      query.value <3>(this -> fkid .value());
    }
 
    assert(query.execute() == 1);
  }
 
  resetDirty_();
}
 
void TotoTyty::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);
  if(flag || ! this -> pouet.isDirty()) this -> pouet = r.get<boost::posix_time::ptime>(2);
  if(flag || ! this -> fkid.isDirty()) this -> fkid = r.get<int32_t>(3);
}
 
void TotoTyty::resetDirty_(void)
{
  this -> id.resetDirty();
  this -> yuyu.resetDirty();
  this -> pouet.resetDirty();
  this -> fkid.resetDirty();
 
  mDirty = false;
}
 
TotoTyty::TotoTyty(void) : 
  PersistenceObjectTmpl<TotoTyty>(true)
{
}
 
std::string TotoTyty::dump(void) const
{
  ACE_Guard<ACE_Thread_Mutex> g(mMutex);
  
  ostringstream d;
 
  d << "gt::hh::ppp::TotoTyty (" << hex << this << dec << ") :";
  d << " " << this -> id.dump();
  d << " " << this -> yuyu.dump();
  d << " " << this -> pouet.dump();
  d << " " << this -> fkid.dump();
 
  return d.str();
}
 
TotoTyty::TotoTyty(RowPtr row) :
	PersistenceObjectTmpl<TotoTyty>(false),
  id(row -> get<int32_t>(0)),
  yuyu(row -> get<std::string>(1)),
  pouet(row -> get<boost::posix_time::ptime>(2)),
  fkid(row -> get<int32_t>(3))
{
}
Personal tools