2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Nathan Binkert
31 #ifndef __BASE_STATS_MYSQL_HH__
32 #define __BASE_STATS_MYSQL_HH__
37 #include "base/stats/output.hh"
38 #include "config/use_mysql.hh"
40 namespace MySQL { class Connection; }
66 unsigned setup(MySqlRun *run);
75 static const size_type maxsize = 1024*1024;
88 InsertData(MySqlRun *_run);
95 class MySql : public Output
98 MySqlRun *run; /* Hide the implementation so we don't have a
103 std::list<FormulaInfo *> formulas;
107 std::map<int, int> idmap;
110 insert(int sim_id, int db_id)
113 idmap.insert(make_pair(sim_id, db_id));
120 map<int,int>::const_iterator i = idmap.find(sim_id);
121 assert(i != idmap.end());
129 void connect(const std::string &host, const std::string &user,
130 const std::string &passwd, const std::string &db,
131 const std::string &name, const std::string &sample,
132 const std::string &project);
133 bool connected() const;
137 virtual void visit(const ScalarInfo &info);
138 virtual void visit(const VectorInfo &info);
139 virtual void visit(const DistInfo &info);
140 virtual void visit(const VectorDistInfo &info);
141 virtual void visit(const Vector2dInfo &info);
142 virtual void visit(const FormulaInfo &info);
145 virtual bool valid() const;
146 virtual void output();
150 void output(const ScalarInfo &info);
151 void output(const VectorInfo &info);
152 void output(const DistInfo &info);
153 void output(const VectorDistInfo &info);
154 void output(const Vector2dInfo &info);
155 void output(const FormulaInfo &info);
156 void output(const DistData &data, const DistParams *params);
159 bool configure(const Info &info, std::string type);
160 void configure(const ScalarInfo &info);
161 void configure(const VectorInfo &info);
162 void configure(const DistInfo &info);
163 void configure(const VectorDistInfo &info);
164 void configure(const Vector2dInfo &info);
165 void configure(const FormulaInfo &info);
168 bool initMySQL(std::string host, std::string database, std::string user,
169 std::string passwd, std::string project, std::string name,
174 initMySQL(std::string host, std::string user, std::string password,
175 std::string database, std::string project, std::string name,
184 #endif // __BASE_STATS_MYSQL_HH__