C++ Class Mapped Google Protocol Buffer Message (二)

2014-11-24 01:21:35 · 作者: · 浏览: 27
ute_in_set = 521,
mute_out_set = 522,
dualstream_set = 523,
conf_call_set = 524,
accept_in_call = 525,
reject_in_call = 526,
conf_drop = 527,
phone_modify = 528,
phone_add = 529,
feec_apply = 530,
phone_histroy_del = 531,
picture_show = 532,
near_key = 533,
far_key = 534,
OK_key = 535,
Ping = 768,
video_loop = 769,
restore = 770,
out_test = 771,
login_console = 1024,
logout_console = 1025,
restart = 1281
};

#pragma db object polymorphic callback(dbevent) table("tblEntity")
class CFocusEntity : public enable_shared_from_this
{
friend class odb::access;
public:
CFocusEntity();
virtual ~CFocusEntity();
unsigned int GetId() const { return id_; }
void SetId(unsigned int val) { id_ = val; }

const std::string & GetName() const { return name_; }
void SetName(const std::string & val) { name_ = val; }

shared_ptr GetParent() const;
void SetParent(const shared_ptr & val) { parent_ = val; }

virtual void dbevent( odb::callback_event e, odb::database& db );
virtual void dbevent( odb::callback_event e, odb::database& db ) const;

bool persist();
bool update();
bool erase();
#ifdef N_ODB
virtual shared_ptr CreateBuild() { return nullptr;}
#endif
void SendIndication();

protected:

void InternalSendIndcation();
private:
#pragma db id auto
unsigned int id_;

std::string name_;

weak_ptr parent_;

};

#pragma db object callback(dbevent) table("tblZone")
class CFocusZone : public CFocusEntity
{
friend class odb::access;
public:
CFocusZone();
~CFocusZone();

void AddEntity( const shared_ptr & en);
void DelEntity( const shared_ptr & en );


void dbevent( odb::callback_event e, odb::database& db );
void dbevent( odb::callback_event e, odb::database& db ) const;

shared_ptr FindEntity( unsigned int id, bool recursive = false) ;
shared_ptr FindEntity( const std::string & name, bool recursive = false) ;
#ifdef N_ODB
void foreach( const std::function & ) > & callback , bool recursive = false, bool isCallItself = false);
virtual shared_ptr CreateBuild();

#endif
static void SetRootZone( const shared_ptr & rootZone_);

static const shared_ptr & GetRootZone();
protected:
static shared_ptr rootZone;
private:
#pragma db inverse(parent_)
std::set< shared_ptr > members_;
std::set< int > int_members_;
std::set< CFocusEntity > raw_members_;

std::map< int ,shared_ptr > map_members_;
std::map< int ,int > map_int_members_;
std::map< int ,CFocusEntity > map_raw_members_;


#ifdef N_ODB
mutable dv::CMutex members_mutex;
#endif

};

#pragma db object callback(dbevent) table("tblTerminal")
class CFocusTerminal : public CFocusEntity
{
friend class odb::access;
public:
CFocusTerminal();
~CFocusTerminal();

const std::string & GetAddress() const { return address_; }
void SetAddress(const std::string & val) { address_ = val; }

unsigned short GetPort() const { return port_; }
void SetPort(unsigned short val) { port_ = val; }

const std::string & GetUsername() const { return username_; }
void SetUsername(const std::string & val) { username_ = val; }

const std::string & GetPassword() const { return password_; }
void SetPassword(const std::string & val) { password_ = val; }




void dbevent( odb::callback_event e, odb::database& db );