StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDbFastSqlWriter.h
1 /***************************************************************************
2  *
3  * $Id: StDbFastSqlWriter.h,v 1.4 2004/01/15 00:02:25 fisyak Exp $
4  *
5  * Author: R. Jeff Porter
6  ***************************************************************************
7  *
8  * Description: implement typeAcceptor for WRITING XML files of DB-tables
9  *
10  ***************************************************************************
11  *
12  * $Log: StDbFastSqlWriter.h,v $
13  * Revision 1.4 2004/01/15 00:02:25 fisyak
14  * Replace ostringstream => StString, add option for alpha
15  *
16  * Revision 1.3 2003/09/16 22:44:17 porter
17  * got rid of all ostrstream objects; replaced with StString+string.
18  * modified rules.make and added file stdb_streams.h for standalone compilation
19  *
20  * Revision 1.2 2003/09/02 17:57:49 perev
21  * gcc 3.2 updates + WarnOff
22  *
23  * Revision 1.1 2003/04/11 22:47:36 porter
24  * Added a fast multi-row write model specifically needed by the daqEventTag
25  * writer. Speed increased from about 100Hz to ~3000Hz. It is only invoked if
26  * the table is marked as Non-Indexed (daqTags & scalers). For non-indexed tables
27  * which include binary stored data (we don't have any yet), the fast writer has
28  * to invoke a slower buffer so that the rates are a bit slower (~500Hz at 50 rows/insert).
29  *
30  * Revision 1.6 2001/10/24 04:05:20 porter
31  * added long long type to I/O and got rid of obsolete dataIndex table
32  *
33  * Revision 1.5 2000/01/10 20:37:55 porter
34  * expanded functionality based on planned additions or feedback from Online work.
35  * update includes:
36  * 1. basis for real transaction model with roll-back
37  * 2. limited SQL access via the manager for run-log & tagDb
38  * 3. balance obtained between enumerated & string access to databases
39  * 4. 3-levels of diagnostic output: Quiet, Normal, Verbose
40  * 5. restructured Node model for better XML support
41  *
42  * Revision 1.4 1999/12/03 17:03:24 porter
43  * added multi-row support for the Xml reader & writer
44  *
45  * Revision 1.3 1999/09/30 02:06:12 porter
46  * add StDbTime to better handle timestamps, modify SQL content (mysqlAccessor)
47  * allow multiple rows (StDbTable), & Added the comment sections at top of
48  * each header and src file
49  *
50  **************************************************************************/
51 #ifndef STDBXMLWRITER_HH
52 #define STDBXMLWRITER_HH
53 
54 #include <stdlib.h>
55 #include <string.h>
56 #include "tableAcceptor.hh"
57 #include "stdb_streams.h"
58 
59 class StString;
60 class StDbTable;
61 
63 
64 protected:
65 
66  StString* os;
67 
68 public:
69 
70  StDbFastSqlWriter(): os(0) {};
71  StDbFastSqlWriter(StString& ofs){ os=&ofs;};
72  virtual ~StDbFastSqlWriter(){};
73 
74  virtual void streamHeader(const char* name) {/* no-op */ };
75  virtual void streamTableName(const char* name){/* no-op */ };
76  virtual void streamEndTableName(){/* no-op */ };
77  virtual void streamAccessor(){/* no-op */ };
78  virtual void endAccessor(){/* no-op */ };
79  virtual void streamRow(int row){/* no-op */ };
80  virtual void streamEndRow(){/* no-op */ };
81  virtual void streamTail(){/* no-op */ };
82  virtual void ioTable(StDbTable* table);
83 
84  virtual void pass(char* name, short& i, int& len) ;
85  virtual void pass(char* name, int& i, int& len);
86  virtual void pass(char* name, long& i, int& len);
87  virtual void pass(char* name, unsigned short& i, int& len) ;
88  virtual void pass(char* name, unsigned int& i, int& len) ;
89  virtual void pass(char* name, unsigned long& i, int& len) ;
90  virtual void pass(char* name, long long& i, int& len) ;
91 
92  virtual void pass(char* name, float& i, int& len);
93  virtual void pass(char* name, double& i, int& len);
94  virtual void pass(char* name, char*& i, int& len);
95  virtual void pass(char* name, unsigned char& i, int& len) ;
96  virtual void pass(char* name, unsigned char*& i, int& len) ;
97  virtual void pass(char* name, short*& i, int& len) ;
98  virtual void pass(char* name, int*& i, int& len);
99  virtual void pass(char* name, long*& i, int& len);
100  virtual void pass(char* name, unsigned short*& i, int& len) ;
101  virtual void pass(char* name, unsigned int*& i, int& len) ;
102  virtual void pass(char* name, unsigned long*& i, int& len) ;
103  virtual void pass(char* name, long long*& i, int& len) ;
104  virtual void pass(char* name, float*& i, int& len);
105  virtual void pass(char* name, double*& i, int& len);
106 
107  //ClassDef(StDbFastSqlWriter,1)
108 
109 };
110 
111 inline void StDbFastSqlWriter::pass(char* name, short& i, int& len){ *os<<","<<i; };
112 inline void StDbFastSqlWriter::pass(char* name, int& i, int& len){ *os<<","<<i; };
113 inline void StDbFastSqlWriter::pass(char* name, long& i, int& len){ *os<<","<<i; };
114 inline void StDbFastSqlWriter::pass(char* name, long long& i, int& len){ *os<<","<<i; };
115 inline void StDbFastSqlWriter::pass(char* name, unsigned short& i, int& len){ *os<<","<<i; };
116 inline void StDbFastSqlWriter::pass(char* name, unsigned char& i, int& len){ *os<<(int)i; };
117 inline void StDbFastSqlWriter::pass(char* name, unsigned int& i, int& len){ *os<<","<<i; };
118 inline void StDbFastSqlWriter::pass(char* name, unsigned long& i, int& len){ *os<<","<<i; };
119 //inline void StDbFastSqlWriter::pass(char* name, unsigned long long& i, int& len){ *os<<","<<i; };
120 inline void StDbFastSqlWriter::pass(char* name, float& i, int& len){ *os<<","<<i; };
121 inline void StDbFastSqlWriter::pass(char* name, double& i, int& len){ *os<<","<<i; };
122 inline void StDbFastSqlWriter::pass(char* name, char*& i, int& len){
123 *os<<",'"<<i<<"'"; };
124 
125 
126 
127 #endif
128 
129 
130 
131 
132 
133 
134 
135 
136 
137