My current lmce_game_bootstrap code:
.cpp
//
// lmce_game_bootstrap.cpp - basic quick little utility I wrote to bootstrap the game database.
//
// Author: Thom Cherryhomes <thom.cherryhomes@localeconcept.com>
//
//
#include "lmce_game_bootstrap.h"
using namespace std;
bool get_game_list(vector<string> &v_sOutput)
{
const char * const args[] = {"/usr/local/bin/mame", "-listfull", NULL};
string sOutput, sStdErr, sGameName;
if (ProcessUtils::GetCommandOutput(args[0], args, sOutput, sStdErr) == 0)
{
vector<string> v_sOutputRows;
StringUtils::Tokenize(sOutput,"\n",v_sOutputRows);
for (unsigned int i=1; i < v_sOutputRows.size(); ++i) // skip over first line :-P
{
sGameName = v_sOutputRows[i].substr(0,8);
sGameName = StringUtils::TrimSpaces(sGameName);
v_sOutput.push_back(sGameName);
}
return true;
}
else
{
return false;
}
}
bool get_metadata_for(string sGameName, map <string,string> &m_sGameData)
{
const char * const args[] = {"/usr/bin/getRomInfo.pl",sGameName.c_str(),NULL};
string sOutput, sStdErr;
if (ProcessUtils::GetCommandOutput(args[0], args, sOutput, sStdErr) == 0)
{
vector<string> v_sOutputRows;
StringUtils::Tokenize(sOutput,"\n",v_sOutputRows);
if (v_sOutputRows[0] == "No Title")
{
return false;
} else
{
m_sGameData["title"] = v_sOutputRows[0];
m_sGameData["year"] = v_sOutputRows[1];
m_sGameData["manufacturer"] = v_sOutputRows[2];
m_sGameData["file"] = v_sOutputRows[3];
m_sGameData["genre"] = v_sOutputRows[4];
return true;
}
} else {
return false;
}
}
bool add_to_database(map<string,string> m_sGameData, class Database_lmce_game *myDatabase)
{
// First, add the file.
string sFilename = m_sGameData["file"] + ".zip";
Row_File *pRow_File = myDatabase->Table_File->AddRow();
pRow_File->FK_GameSystem_set(GAMESYSTEM_MAME_CONST);
pRow_File->Filename_set(sFilename);
myDatabase->Table_File->Commit();
// Then, add the Title Attribute->
Row_Attribute *pRow_Attribute = myDatabase->Table_Attribute->AddRow();
pRow_Attribute->FK_AttributeType_set(ATTRIBUTETYPE_title_CONST);
pRow_Attribute->FK_GameSystem_set(GAMESYSTEM_MAME_CONST);
pRow_Attribute->Name_set(m_sGameData["title"]);
myDatabase->Table_Attribute->Commit();
// Then, add the Title Attribute to the file->
Row_File_Attribute *pRow_File_Attribute = myDatabase->File_Attribute_get()->AddRow();
pRow_File_Attribute->FK_File_set(pRow_File->PK_File_get());
pRow_File_Attribute->FK_Attribute_set(pRow_Attribute->PK_Attribute_get());
myDatabase->Table_File_Attribute->Commit();
// Then, add the Year Attribute->
pRow_Attribute = myDatabase->Table_Attribute->AddRow();
pRow_Attribute->FK_AttributeType_set(ATTRIBUTETYPE_year_CONST);
pRow_Attribute->FK_GameSystem_set(GAMESYSTEM_MAME_CONST);
pRow_Attribute->Name_set(m_sGameData["year"]);
myDatabase->Table_Attribute->Commit();
// Then, add the Year Attribute to the file->
pRow_File_Attribute = myDatabase->Table_File_Attribute->AddRow();
pRow_File_Attribute->FK_File_set(pRow_File->PK_File_get());
pRow_File_Attribute->FK_Attribute_set(pRow_Attribute->PK_Attribute_get());
myDatabase->Table_File_Attribute->Commit();
// Then, add the Manufacturer Attribute->
pRow_Attribute = myDatabase->Table_Attribute->AddRow();
pRow_Attribute->FK_AttributeType_set(ATTRIBUTETYPE_manufacturer_CONST);
pRow_Attribute->FK_GameSystem_set(GAMESYSTEM_MAME_CONST);
pRow_Attribute->Name_set(m_sGameData["manufacturer"]);
myDatabase->Table_Attribute->Commit();
// Then, add the Manufacturer Attribute to the file->
pRow_File_Attribute = myDatabase->Table_File_Attribute->AddRow();
pRow_File_Attribute->FK_File_set(pRow_File->PK_File_get());
pRow_File_Attribute->FK_Attribute_set(pRow_Attribute->PK_Attribute_get());
myDatabase->Table_File_Attribute->Commit();
// Then, add the Genre Attribute->
pRow_Attribute = myDatabase->Table_Attribute->AddRow();
pRow_Attribute->FK_AttributeType_set(ATTRIBUTETYPE_genre_CONST);
pRow_Attribute->FK_GameSystem_set(GAMESYSTEM_MAME_CONST);
pRow_Attribute->Name_set(m_sGameData["genre"]);
myDatabase->Table_Attribute->Commit();
// Then, add the Genre Attribute to the file->
pRow_File_Attribute = myDatabase->Table_File_Attribute->AddRow();
pRow_File_Attribute->FK_File_set(pRow_File->PK_File_get());
pRow_File_Attribute->FK_Attribute_set(pRow_Attribute->PK_Attribute_get());
myDatabase->File_Attribute->Commit();
// delete(pRow_File);
// delete(pRow_Attribute);
// delete(pRow_File_Attribute);
return true;
}
int main(int argc, char* argv[])
{
vector<string> v_sGameList;
map<string,string> m_sGameData;
cout << "lmce_game_bootstrap 0.1" << endl;
cout << endl << endl;
Database_lmce_game *myDatabase;
myDatabase = new Database_lmce_game(LoggerWrapper::GetInstance());
myDatabase->Connect("localhost","root","","lmce_game",3306);
if (!get_game_list(v_sGameList)) {
cout << "Unable to retrieve game list." << endl;
return 1;
}
// Main Loop
for (unsigned int i=0; i<v_sGameList.size(); ++i)
{
if (!get_metadata_for(v_sGameList[i],m_sGameData))
{
cout << "Unable to get game data for: " << v_sGameList[i] << endl;
}
else
{
if (!add_to_database(m_sGameData,myDatabase))
{
cout << "Unable to add game data for: " << v_sGameList[i] << " to database." << endl;
}
else
{
cout << "Added " << v_sGameList[i] << " to database." << endl;
}
}
}
cout << "Complete." << endl;
}
.h
//
// lmce_game_bootstrap.h - basic quick little utility I wrote to bootstrap the game database.
//
#include <string>
#include <map>
#include <vector>
#include <iostream>
#include "lmce_game/Database_lmce_game.h"
#include "lmce_game/Define_AttributeType.h"
#include "lmce_game/Define_File_Attribute.h"
#include "lmce_game/TableRow.h"
#include "lmce_game/Table_AttributeType.h"
#include "lmce_game/Table_File_Attribute.h"
#include "lmce_game/Define_Attribute.h"
#include "lmce_game/Define_File.h"
#include "lmce_game/Define_GameSystem.h"
#include "lmce_game/Table_Attribute.h"
#include "lmce_game/Table_File.h"
#include "lmce_game/Table_GameSystem.h"
#include "PlutoUtils/ProcessUtils.h"
#include "PlutoUtils/StringUtils.h"
#include "PlutoUtils/DBHelper.h"
#include "DCE/Logger.h"
bool get_game_list(vector<string> &v_sOutput);
bool get_metadata_for(string sGameName, map <string,string> &m_sGameData);
bool add_to_database(map<string,string> m_sGameData, class Database_lmce_game *myDatabase);
int main(int argc, char* argv[]);
and I get the following compiler output:
Computing dependencies for Main.cpp done
g++ -c -I.. -I../DCE -I/usr/include/mysql -DKDE_LMCE -DDEBUG -DTHREAD_LOG -DLOG_ALL_QUERIES -I/opt/libxine1-pluto/include -I/opt/linphone-1.3.5/include -Wall -fPIC -ggdb3 Main.cpp -o Main.o
Main.cpp: In function ‘bool add_to_database(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, Database_lmce_game*)’:
Main.cpp:68: error: ‘class Database_lmce_game’ has no member named ‘Table_File’
Main.cpp:71: error: ‘class Database_lmce_game’ has no member named ‘Table_File’
Main.cpp:74: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:78: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:84: error: ‘class Database_lmce_game’ has no member named ‘Table_File_Attribute’
Main.cpp:87: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:91: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:94: error: ‘class Database_lmce_game’ has no member named ‘Table_File_Attribute’
Main.cpp:97: error: ‘class Database_lmce_game’ has no member named ‘Table_File_Attribute’
Main.cpp:100: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:104: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:107: error: ‘class Database_lmce_game’ has no member named ‘Table_File_Attribute’
Main.cpp:110: error: ‘class Database_lmce_game’ has no member named ‘Table_File_Attribute’
Main.cpp:113: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:117: error: ‘class Database_lmce_game’ has no member named ‘Table_Attribute’
Main.cpp:120: error: ‘class Database_lmce_game’ has no member named ‘Table_File_Attribute’
Main.cpp:123: error: ‘class Database_lmce_game’ has no member named ‘File_Attribute’
make: *** [Main.o] Error 1
I am losing my mind..because I SEE THE FREAKIN MEMBERS IN THERE, BUT #@)$#@)$#@)$@#) WTH?!

-Thom