Update code to work with thrift 0.9.x.

This commit is contained in:
Marc Burns 2012-11-19 18:33:59 -05:00
parent c6bdc84f0b
commit 904959de20
10 changed files with 564 additions and 494 deletions

View File

@ -2,9 +2,9 @@
CXX = @g++
ifndef NDEBUG
CXXFLAGS = -g -O0 -Wall -I/users/m4burns/thrift/include/thrift -I. -Igen-cpp
CXXFLAGS = -g -O0 -Wall -I/users/m4burns/thrift/include -I. -Igen-cpp
else
CXXFLAGS = -O3 -fexpensive-optimizations -ffast-math -fno-math-errno -Wall -I/users/m4burns/thrift/include/thrift -I. -Igen-cpp
CXXFLAGS = -O3 -fexpensive-optimizations -ffast-math -fno-math-errno -Wall -I/users/m4burns/thrift/include -I. -Igen-cpp
endif
LDFLAGS = /users/m4burns/thrift/lib/libthriftnb.a /users/m4burns/thrift/lib/libthrift.a -levent

View File

@ -1,8 +1,8 @@
#include <stdio.h>
#include <unistd.h>
#include <protocol/TBinaryProtocol.h>
#include <transport/TSocket.h>
#include <transport/TTransportUtils.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include "Pos.h"
#include "sha1.h"
#include <iostream>

View File

@ -1,8 +1,8 @@
#include <stdio.h>
#include <unistd.h>
#include <protocol/TBinaryProtocol.h>
#include <transport/TSocket.h>
#include <transport/TTransportUtils.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/transport/TSocket.h>
#include <thrift/transport/TTransportUtils.h>
#include "Pos.h"
#include "sha1.h"
#include <iostream>

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#ifndef Pos_H
#define Pos_H
#include <TProcessor.h>
#include <thrift/TDispatchProcessor.h>
#include "pos_types.h"
namespace pos {
@ -36,6 +37,30 @@ class PosIf {
virtual void toString(std::vector<std::string> & _return) = 0;
};
class PosIfFactory {
public:
typedef PosIf Handler;
virtual ~PosIfFactory() {}
virtual PosIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) = 0;
virtual void releaseHandler(PosIf* /* handler */) = 0;
};
class PosIfSingletonFactory : virtual public PosIfFactory {
public:
PosIfSingletonFactory(const boost::shared_ptr<PosIf>& iface) : iface_(iface) {}
virtual ~PosIfSingletonFactory() {}
virtual PosIf* getHandler(const ::apache::thrift::TConnectionInfo&) {
return iface_.get();
}
virtual void releaseHandler(PosIf* /* handler */) {}
protected:
boost::shared_ptr<PosIf> iface_;
};
class PosNull : virtual public PosIf {
public:
virtual ~PosNull() {}
@ -235,7 +260,7 @@ typedef struct _Pos_getSalt_result__isset {
class Pos_getSalt_result {
public:
Pos_getSalt_result() : success("") {
Pos_getSalt_result() : success() {
}
virtual ~Pos_getSalt_result() throw() {}
@ -292,7 +317,7 @@ typedef struct _Pos_getAccountFromHash_args__isset {
class Pos_getAccountFromHash_args {
public:
Pos_getAccountFromHash_args() : dataToHash("") {
Pos_getAccountFromHash_args() : dataToHash() {
}
virtual ~Pos_getAccountFromHash_args() throw() {}
@ -508,7 +533,7 @@ typedef struct _Pos_getHashesFromAccountName_args__isset {
class Pos_getHashesFromAccountName_args {
public:
Pos_getHashesFromAccountName_args() : account("") {
Pos_getHashesFromAccountName_args() : account() {
}
virtual ~Pos_getHashesFromAccountName_args() throw() {}
@ -616,7 +641,7 @@ typedef struct _Pos_getHashAccountBalance_args__isset {
class Pos_getHashAccountBalance_args {
public:
Pos_getHashAccountBalance_args() : dataToHash("") {
Pos_getHashAccountBalance_args() : dataToHash() {
}
virtual ~Pos_getHashAccountBalance_args() throw() {}
@ -832,7 +857,7 @@ typedef struct _Pos_getNameAccountBalance_args__isset {
class Pos_getNameAccountBalance_args {
public:
Pos_getNameAccountBalance_args() : account("") {
Pos_getNameAccountBalance_args() : account() {
}
virtual ~Pos_getNameAccountBalance_args() throw() {}
@ -942,7 +967,7 @@ typedef struct _Pos_associateHashWithId_args__isset {
class Pos_associateHashWithId_args {
public:
Pos_associateHashWithId_args() : auth(""), dataToHash(""), account(0) {
Pos_associateHashWithId_args() : auth(), dataToHash(), account(0) {
}
virtual ~Pos_associateHashWithId_args() throw() {}
@ -1068,7 +1093,7 @@ typedef struct _Pos_associateHashWithName_args__isset {
class Pos_associateHashWithName_args {
public:
Pos_associateHashWithName_args() : auth(""), dataToHash(""), account("") {
Pos_associateHashWithName_args() : auth(), dataToHash(), account() {
}
virtual ~Pos_associateHashWithName_args() throw() {}
@ -1193,7 +1218,7 @@ typedef struct _Pos_deassociateHash_args__isset {
class Pos_deassociateHash_args {
public:
Pos_deassociateHash_args() : auth(""), dataToHash("") {
Pos_deassociateHash_args() : auth(), dataToHash() {
}
virtual ~Pos_deassociateHash_args() throw() {}
@ -1419,7 +1444,7 @@ typedef struct _Pos_setUPCPrice_args__isset {
class Pos_setUPCPrice_args {
public:
Pos_setUPCPrice_args() : auth(""), upc(0), price(0) {
Pos_setUPCPrice_args() : auth(), upc(0), price(0) {
}
virtual ~Pos_setUPCPrice_args() throw() {}
@ -1545,7 +1570,7 @@ typedef struct _Pos_doTransactionOnHash_args__isset {
class Pos_doTransactionOnHash_args {
public:
Pos_doTransactionOnHash_args() : auth(""), dataToHash(""), delta(0) {
Pos_doTransactionOnHash_args() : auth(), dataToHash(), delta(0) {
}
virtual ~Pos_doTransactionOnHash_args() throw() {}
@ -1671,7 +1696,7 @@ typedef struct _Pos_doTransactionOnId_args__isset {
class Pos_doTransactionOnId_args {
public:
Pos_doTransactionOnId_args() : auth(""), account(0), delta(0) {
Pos_doTransactionOnId_args() : auth(), account(0), delta(0) {
}
virtual ~Pos_doTransactionOnId_args() throw() {}
@ -1797,7 +1822,7 @@ typedef struct _Pos_doTransactionOnName_args__isset {
class Pos_doTransactionOnName_args {
public:
Pos_doTransactionOnName_args() : auth(""), account(""), delta(0) {
Pos_doTransactionOnName_args() : auth(), account(), delta(0) {
}
virtual ~Pos_doTransactionOnName_args() throw() {}
@ -1922,7 +1947,7 @@ typedef struct _Pos_revertTransaction_args__isset {
class Pos_revertTransaction_args {
public:
Pos_revertTransaction_args() : auth(""), serial(0) {
Pos_revertTransaction_args() : auth(), serial(0) {
}
virtual ~Pos_revertTransaction_args() throw() {}
@ -2148,7 +2173,7 @@ typedef struct _Pos_doStockChange_args__isset {
class Pos_doStockChange_args {
public:
Pos_doStockChange_args() : auth(""), upc(0), delta(0) {
Pos_doStockChange_args() : auth(), upc(0), delta(0) {
}
virtual ~Pos_doStockChange_args() throw() {}
@ -2445,12 +2470,14 @@ class PosClient : virtual public PosIf {
::apache::thrift::protocol::TProtocol* oprot_;
};
class PosProcessor : virtual public ::apache::thrift::TProcessor {
class PosProcessor : public ::apache::thrift::TDispatchProcessor {
protected:
boost::shared_ptr<PosIf> iface_;
virtual bool process_fn(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, std::string& fname, int32_t seqid, void* callContext);
virtual bool dispatchCall(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, const std::string& fname, int32_t seqid, void* callContext);
private:
std::map<std::string, void (PosProcessor::*)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*)> processMap_;
typedef void (PosProcessor::*ProcessFunction)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*);
typedef std::map<std::string, ProcessFunction> ProcessMap;
ProcessMap processMap_;
void process_ping(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
void process_getSalt(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
void process_getAccountFromHash(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
@ -2496,10 +2523,20 @@ class PosProcessor : virtual public ::apache::thrift::TProcessor {
processMap_["toString"] = &PosProcessor::process_toString;
}
virtual bool process(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot, boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot, void* callContext);
virtual ~PosProcessor() {}
};
class PosProcessorFactory : public ::apache::thrift::TProcessorFactory {
public:
PosProcessorFactory(const ::boost::shared_ptr< PosIfFactory >& handlerFactory) :
handlerFactory_(handlerFactory) {}
::boost::shared_ptr< ::apache::thrift::TProcessor > getProcessor(const ::apache::thrift::TConnectionInfo& connInfo);
protected:
::boost::shared_ptr< PosIfFactory > handlerFactory_;
};
class PosMultiface : virtual public PosIf {
public:
PosMultiface(std::vector<boost::shared_ptr<PosIf> >& ifaces) : ifaces_(ifaces) {
@ -2514,222 +2551,186 @@ class PosMultiface : virtual public PosIf {
public:
void ping() {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->ping();
}
ifaces_[i]->ping();
}
void getSalt(std::string& _return) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
ifaces_[i]->getSalt(_return);
return;
} else {
ifaces_[i]->getSalt(_return);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getSalt(_return);
}
ifaces_[i]->getSalt(_return);
return;
}
int32_t getAccountFromHash(const std::string& dataToHash) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->getAccountFromHash(dataToHash);
} else {
ifaces_[i]->getAccountFromHash(dataToHash);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getAccountFromHash(dataToHash);
}
return ifaces_[i]->getAccountFromHash(dataToHash);
}
void getHashesFromAccountId(std::vector<std::string> & _return, const int32_t account) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
ifaces_[i]->getHashesFromAccountId(_return, account);
return;
} else {
ifaces_[i]->getHashesFromAccountId(_return, account);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getHashesFromAccountId(_return, account);
}
ifaces_[i]->getHashesFromAccountId(_return, account);
return;
}
void getHashesFromAccountName(std::vector<std::string> & _return, const std::string& account) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
ifaces_[i]->getHashesFromAccountName(_return, account);
return;
} else {
ifaces_[i]->getHashesFromAccountName(_return, account);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getHashesFromAccountName(_return, account);
}
ifaces_[i]->getHashesFromAccountName(_return, account);
return;
}
int32_t getHashAccountBalance(const std::string& dataToHash) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->getHashAccountBalance(dataToHash);
} else {
ifaces_[i]->getHashAccountBalance(dataToHash);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getHashAccountBalance(dataToHash);
}
return ifaces_[i]->getHashAccountBalance(dataToHash);
}
int32_t getIdAccountBalance(const int32_t account) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->getIdAccountBalance(account);
} else {
ifaces_[i]->getIdAccountBalance(account);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getIdAccountBalance(account);
}
return ifaces_[i]->getIdAccountBalance(account);
}
int32_t getNameAccountBalance(const std::string& account) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->getNameAccountBalance(account);
} else {
ifaces_[i]->getNameAccountBalance(account);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getNameAccountBalance(account);
}
return ifaces_[i]->getNameAccountBalance(account);
}
int64_t associateHashWithId(const std::string& auth, const std::string& dataToHash, const int32_t account) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->associateHashWithId(auth, dataToHash, account);
} else {
ifaces_[i]->associateHashWithId(auth, dataToHash, account);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->associateHashWithId(auth, dataToHash, account);
}
return ifaces_[i]->associateHashWithId(auth, dataToHash, account);
}
int64_t associateHashWithName(const std::string& auth, const std::string& dataToHash, const std::string& account) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->associateHashWithName(auth, dataToHash, account);
} else {
ifaces_[i]->associateHashWithName(auth, dataToHash, account);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->associateHashWithName(auth, dataToHash, account);
}
return ifaces_[i]->associateHashWithName(auth, dataToHash, account);
}
int64_t deassociateHash(const std::string& auth, const std::string& dataToHash) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->deassociateHash(auth, dataToHash);
} else {
ifaces_[i]->deassociateHash(auth, dataToHash);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->deassociateHash(auth, dataToHash);
}
return ifaces_[i]->deassociateHash(auth, dataToHash);
}
int32_t getUPCPrice(const int64_t upc) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->getUPCPrice(upc);
} else {
ifaces_[i]->getUPCPrice(upc);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getUPCPrice(upc);
}
return ifaces_[i]->getUPCPrice(upc);
}
int64_t setUPCPrice(const std::string& auth, const int64_t upc, const int32_t price) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->setUPCPrice(auth, upc, price);
} else {
ifaces_[i]->setUPCPrice(auth, upc, price);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->setUPCPrice(auth, upc, price);
}
return ifaces_[i]->setUPCPrice(auth, upc, price);
}
int64_t doTransactionOnHash(const std::string& auth, const std::string& dataToHash, const int32_t delta) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->doTransactionOnHash(auth, dataToHash, delta);
} else {
ifaces_[i]->doTransactionOnHash(auth, dataToHash, delta);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->doTransactionOnHash(auth, dataToHash, delta);
}
return ifaces_[i]->doTransactionOnHash(auth, dataToHash, delta);
}
int64_t doTransactionOnId(const std::string& auth, const int32_t account, const int32_t delta) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->doTransactionOnId(auth, account, delta);
} else {
ifaces_[i]->doTransactionOnId(auth, account, delta);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->doTransactionOnId(auth, account, delta);
}
return ifaces_[i]->doTransactionOnId(auth, account, delta);
}
int64_t doTransactionOnName(const std::string& auth, const std::string& account, const int32_t delta) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->doTransactionOnName(auth, account, delta);
} else {
ifaces_[i]->doTransactionOnName(auth, account, delta);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->doTransactionOnName(auth, account, delta);
}
return ifaces_[i]->doTransactionOnName(auth, account, delta);
}
int64_t revertTransaction(const std::string& auth, const int64_t serial) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->revertTransaction(auth, serial);
} else {
ifaces_[i]->revertTransaction(auth, serial);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->revertTransaction(auth, serial);
}
return ifaces_[i]->revertTransaction(auth, serial);
}
int32_t getStock(const int64_t upc) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->getStock(upc);
} else {
ifaces_[i]->getStock(upc);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->getStock(upc);
}
return ifaces_[i]->getStock(upc);
}
int64_t doStockChange(const std::string& auth, const int64_t upc, const int32_t delta) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
return ifaces_[i]->doStockChange(auth, upc, delta);
} else {
ifaces_[i]->doStockChange(auth, upc, delta);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->doStockChange(auth, upc, delta);
}
return ifaces_[i]->doStockChange(auth, upc, delta);
}
void toString(std::vector<std::string> & _return) {
size_t sz = ifaces_.size();
for (size_t i = 0; i < sz; ++i) {
if (i == sz - 1) {
ifaces_[i]->toString(_return);
return;
} else {
ifaces_[i]->toString(_return);
}
size_t i = 0;
for (; i < (sz - 1); ++i) {
ifaces_[i]->toString(_return);
}
ifaces_[i]->toString(_return);
return;
}
};

View File

@ -1,11 +1,13 @@
// This autogenerated skeleton file illustrates how to build a server.
// You should copy it to another filename to avoid overwriting it.
#include <stdint.h>
#include "Pos.h"
#include <protocol/TBinaryProtocol.h>
#include <server/TNonblockingServer.h>
#include <transport/TServerSocket.h>
#include <transport/TBufferTransports.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/server/TSimpleServer.h>
#include <thrift/server/TNonblockingServer.h>
#include <thrift/transport/TServerSocket.h>
#include <thrift/transport/TBufferTransports.h>
#include <iostream>
#include "db_if.h"
#include "posdb.h"
@ -18,7 +20,7 @@ using namespace ::apache::thrift::server;
using boost::shared_ptr;
using namespace pos;
using namespace ::pos;
DbIf * d;

View File

@ -1,7 +1,8 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#include "pos_constants.h"

View File

@ -1,7 +1,8 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#ifndef pos_CONSTANTS_H
#define pos_CONSTANTS_H

View File

@ -1,10 +1,13 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#include "pos_types.h"
#include <algorithm>
namespace pos {
} // namespace

View File

@ -1,17 +1,17 @@
/**
* Autogenerated by Thrift Compiler (0.7.0)
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#ifndef pos_TYPES_H
#define pos_TYPES_H
#include <Thrift.h>
#include <TApplicationException.h>
#include <protocol/TProtocol.h>
#include <transport/TTransport.h>
#include <stdint.h>
#include <thrift/Thrift.h>
#include <thrift/TApplicationException.h>
#include <thrift/protocol/TProtocol.h>
#include <thrift/transport/TTransport.h>
namespace pos {