cadbc Class Reference

#include <cadbc.h>

List of all members.

Public Member Functions

 cadbc (const string &host, int port, int rcvbfsz=100000)
 ~cadbc ()
void login (const char user[], const char passwd[])
const char * getPeptideFasta (const string &pepName) throw (pepNotFound)
const char * getPeptideString (const string &pepName) throw (pepNotFound)
const char * getDNAFasta (const string &seqname) throw (DNANotFound)
const char * getDNAString (const string &seqname) throw (DNANotFound)
const char * fas2str ()
Aceobjfetch (const string &objType, const string &objName) throw (AceException)
void aql (const string &query) throw (AQLException)
int fields () const
string fieldName (int i) const
string fieldType (int i) const
bool next ()
string getvalue (int i)
char * query (const string q)
char * query (const char q[])
char * getBody () const
int getBodyLength () const
char * getNext ()
int send_msg (const char msgType[], const char body[], int body_len)
int send_msg (const char msgType[], const char body[])
int send_msg (const char msgType[], const string &body)
int receive ()
int getMaxBytes () const
int getMsgLen () const
void setMsgLen (int l)
const char * getMsgType () const
void setMsgType (const char mt[])
int getSockbufSize ()
void setSockbufSize (int sz)
void show ()

Static Public Attributes

static const int HEADER_LEN = 50
static const char * OK = "ACESERV_MSGOK"
static const char * REQ = "ACESERV_MSGREQ"
static const char * FAIL = "ACESERV_MSGOK"
static const char * DATA = "ACESERV_MSGDATA"
static const char * ENCORE = "ACESERV_MSGENCORE"
static const char * KILL = "ACESERV_MSGKILL"

Private Member Functions

string & completeQuery (const string &query)
void showHeader ()

Private Attributes

char * msg
int msglen
int msgMaxlen
int maxBytes
int sock
sockaddr_in svaddr
string result
Aceobj obj
vector< string > columns
char * aqlResult
char * nextRow
vector< string > currRow

Static Private Attributes

static const int faswidth = 50

Friends

class Result


Constructor & Destructor Documentation

cadbc::cadbc ( const string &  host,
int  port,
int  rcvbfsz = 100000 
)

no need to return status, use exception handling static const int TUPLES_OK = 101; static const int QUERY_FAIL = 102; initialize msgMaxlen(200), msg(0), set sock receive_buffer to rcvbfsz for large sequence it is better to set receive_buffer size to a very large value. The two overloaded version caused big trouble the string version is sufficient because there will be a implicit conversion of char* to string.

Parameters:
host host ip address
port the port that saceserver is serving on
host if a ddd.ddd.ddd.ddd format, it should handle the name format host 127.0.0.1 instead of localhost, I still need to learn more about the unix esp. the linux internet address utilities

References connect(), msg, msgMaxlen, one, sock, and svaddr.

cadbc::~cadbc (  )  [inline]

References msg, and sock.


Member Function Documentation

void cadbc::login ( const char  user[],
const char  passwd[] 
)

const char * cadbc::getPeptideFasta ( const string &  pepName  )  throw (pepNotFound)

The user must make a copy of this pointer. It will disappear after calling another command to the server. In fasta format with header.

calling find peptide also requires two steps: find peptide, then show. This method is not assumed to do ENCORE so we can simplify this methods to use only the msg string.

References ENCORE, getBody(), getMsgType(), msglen, receive(), REQ, and send_msg().

Referenced by getPeptideString(), and main().

const char * cadbc::getPeptideString ( const string &  pepName  )  throw (pepNotFound)

References fas2str(), and getPeptideFasta().

Referenced by getPep(), and main().

const char * cadbc::getDNAFasta ( const string &  seqname  )  throw (DNANotFound)

same as getPeptideString and getPeptideFasta store the sequence in class member result. if making another call to the server will destroy the result It is returning a reference for efficiency reasons. use getBodyLength() to obtain the length of the DNA or Peptide sequence The char* will disappear after calling any function. So you must save the result or make a copy of the result.

The last line contains
folowed by

the fasta sequence has the last line terminated by
the is after

References ENCORE, getBody(), getMsgType(), msg, msglen, receive(), REQ, and send_msg().

Referenced by getDNAString().

const char * cadbc::getDNAString ( const string &  seqname  )  throw (DNANotFound)

References fas2str(), and getDNAFasta().

Referenced by main().

const char * cadbc::fas2str (  ) 

helper function, converts the underlying fasta formated sequence stored in result into a string. You must call getDNAFasta or getPeptideFasta before calling this function. It is mainly used internally by getDNAString or getPeptideString.

this function does not need to allocate memory

References faswidth, getBody(), msg, and msglen.

Referenced by getDNAString(), and getPeptideString().

Aceobj * cadbc::fetch ( const string &  objType,
const string &  objName 
) throw (AceException)

void cadbc::aql ( const string &  query  )  throw (AQLException)

the following methods are used by Result to construct the Result object The result object provides random access.

After executing aql, the result is saved in msg. The server will not do encore on aql.

the -h format is much cleanner. It can save some trouble to check the extra prefix.

References aqlResult, columns, currRow, getBody(), nextRow, query(), receive(), REQ, and send_msg().

Referenced by main().

int cadbc::fields (  )  const [inline]

References columns.

Referenced by main().

string cadbc::fieldName ( int  i  )  const [inline]

References columns.

string cadbc::fieldType ( int  i  )  const [inline]

References columns.

Referenced by main().

bool cadbc::next (  ) 

problem with sharing the buffer msg with other query commands. This method will not work, if calling any query commands that changes msg buffer

External Object that copy the msg result should be implemented to ensure safe usage of the result.

next return true if there is still another row of. It will advance the pointer to the next row.

I learned from Ed that aql does not realy do ENCORE so I don't realy need to do this.

References aqlResult, columns, currRow, nextRow, and string().

Referenced by main().

string cadbc::getvalue ( int  i  )  [inline]

getvalue should only be called after calling next

References currRow.

Referenced by main().

char* cadbc::query ( const string  q  )  [inline]

Referenced by aql().

char* cadbc::query ( const char  q[]  )  [inline]

References getBody(), receive(), and send_msg().

char* cadbc::getBody (  )  const [inline]

int cadbc::getBodyLength (  )  const [inline]

References HEADER_LEN, and msglen.

char* cadbc::getNext (  )  [inline]

References getBody(), receive(), and send_msg().

int cadbc::send_msg ( const char  msgType[],
const char  body[],
int  body_len 
)

msg_len must be the length of the string + 1 (the null bit) msg_len = strlen(body) + 1 except for the hello message where the "bonjour" is set to length 13

References HEADER_LEN, msg, msgMaxlen, setMsgLen(), setMsgType(), and sock.

Referenced by aql(), completeQuery(), fetch(), getDNAFasta(), getNext(), getPeptideFasta(), query(), and send_msg().

int cadbc::send_msg ( const char  msgType[],
const char  body[] 
) [inline]

References send_msg().

int cadbc::send_msg ( const char  msgType[],
const string &  body 
) [inline]

References send_msg().

int cadbc::receive (  ) 

will store the message in the object's member msg need to call getBody to retrieve the result.

References getMsgLen(), HEADER_LEN, msg, msglen, msgMaxlen, show(), and sock.

Referenced by aql(), completeQuery(), fetch(), getDNAFasta(), getNext(), getPeptideFasta(), and query().

int cadbc::getMaxBytes (  )  const [inline]

References msg.

int cadbc::getMsgLen (  )  const [inline]

References msg.

Referenced by login(), and receive().

void cadbc::setMsgLen ( int  l  )  [inline]

References msg.

Referenced by send_msg().

const char* cadbc::getMsgType (  )  const [inline]

References msg.

Referenced by completeQuery(), getDNAFasta(), and getPeptideFasta().

void cadbc::setMsgType ( const char  mt[]  )  [inline]

References msg.

Referenced by send_msg().

int cadbc::getSockbufSize (  ) 

References sock.

void cadbc::setSockbufSize ( int  sz  ) 

References sock.

void cadbc::show (  ) 

References HEADER_LEN, and msg.

Referenced by login(), and receive().

string & cadbc::completeQuery ( const string &  query  )  [private]

Put all query result into the result member. if there are multiple encores it will fetch all the fragments and assemble it into result. This method should be used for getting protein or DNA sequences. And obtaining the complete objects.

return the reference to the result.

References ENCORE, getBody(), getMsgType(), receive(), REQ, result, and send_msg().

Referenced by fetch().

void cadbc::showHeader (  )  [private]

these are debuging functions

References HEADER_LEN, and msg.


Friends And Related Function Documentation

friend class Result [friend]


Member Data Documentation

const int cadbc::HEADER_LEN = 50 [static]

const char * cadbc::OK = "ACESERV_MSGOK" [static]

const char * cadbc::REQ = "ACESERV_MSGREQ" [static]

const char * cadbc::FAIL = "ACESERV_MSGOK" [static]

const char * cadbc::DATA = "ACESERV_MSGDATA" [static]

const char * cadbc::ENCORE = "ACESERV_MSGENCORE" [static]

const char * cadbc::KILL = "ACESERV_MSGKILL" [static]

char* cadbc::msg [private]

int cadbc::msglen [private]

maxBytes+HEADER_LEN currently 102450 may be redundant with maxBytes. When Length is very long, much longer than maxBytes I will reallocate enought room for msg to message length and update msgMaxlen to length of this large message.

This will set msgMaxlen > maxBytes+50

Referenced by fas2str(), getBodyLength(), getDNAFasta(), getPeptideFasta(), and receive().

int cadbc::msgMaxlen [private]

Referenced by cadbc(), login(), receive(), and send_msg().

int cadbc::maxBytes [private]

the allocated msg length with one extra byte for set after login and changed if some query returns long results. maxBytes may be smaller than msgMaxlen owing to an error in the server

Referenced by login().

int cadbc::sock [private]

sockaddr_in cadbc::svaddr [private]

Referenced by cadbc().

string cadbc::result [private]

result is the larger buffer to hold query results that are too long and needs to be concatenated into a complete string, such as long genomic DNA sequences.

Referenced by completeQuery(), and fetch().

const int cadbc::faswidth = 50 [static, private]

Referenced by fas2str().

Aceobj cadbc::obj [private]

the object uses its own buffer and will not interfere with other operations using msg buffer

Referenced by fetch().

vector<string> cadbc::columns [private]

for aql query result management the DataType of columns

Referenced by aql(), fieldName(), fields(), fieldType(), and next().

char* cadbc::aqlResult [private]

Referenced by aql(), and next().

char* cadbc::nextRow [private]

Referenced by aql(), and next().

vector<string> cadbc::currRow [private]

empty string in the vector represents NULL after calling next, the currRow contains the result, the nextRow pointer will point to the next row

Referenced by aql(), getvalue(), and next().


The documentation for this class was generated from the following files:

Generated on Wed Aug 10 11:57:08 2011 for Softwares from Orpara by  doxygen 1.5.6