Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
RJ committed Mar 7, 2009
1 parent bc34ed2 commit 9f2efc0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
8 changes: 7 additions & 1 deletion playdar-daemon/etc/schema.sql
Expand Up @@ -77,4 +77,10 @@ CREATE TABLE IF NOT EXISTS file_join (

--


CREATE TABLE IF NOT EXISTS settings (
category TEXT NOT NULL,
key TEXT NOT NULL,
value TEXT,
description TEXT
);
CREATE PRIMARY KEY ON settings(category,key);
7 changes: 7 additions & 0 deletions playdar-daemon/src/application/application.cpp
Expand Up @@ -14,15 +14,22 @@ MyApplication::MyApplication(boost::program_options::variables_map opt)

m_po = opt;
string db_path = option<string>("app.db");
m_db = sqlite3pp::database(db_path.c_str());

m_library = new Library( db_path, this );
m_resolver = new Resolver(this);
}

MyApplication::~MyApplication()
{
delete(m_library);
delete(m_resolver);
}





string
MyApplication::gen_uuid()
{
Expand Down
16 changes: 15 additions & 1 deletion playdar-daemon/src/application/application.h
Expand Up @@ -7,7 +7,7 @@

#include "application/types.h"
#include <boost/thread.hpp>

#include "sqlite3pp.h"
#include <boost/program_options.hpp>


Expand Down Expand Up @@ -42,6 +42,18 @@ class MyApplication
template <typename T> T option(string o, T def);
template <typename T> T option(string o);

template <typename T>
opt(string cat, string key, T def)
{
sqlite3pp::query qry(m_db, string("SELECT value FROM setting WHERE lower(category)=? AND lower(key)=?").c_str() );
qry.bind(1, cat);
qry.bind(2, key);
for(sqlite3pp::query::iterator i = qry.begin(); i!=qry.end(); ++i){
return boost::lexical_cast<T>((*i).get<const char *>(0));
break; // should only be one row
}
return def;
}

// RANDOM UTILITY FUNCTIONS TOSSED IN HERE FOR NOW:

Expand All @@ -58,6 +70,8 @@ class MyApplication


private:
sqlite3pp::database m_db;
sqlite3pp::database * db(){ return &m_db; }
Library * m_library;
Resolver * m_resolver;
boost::program_options::variables_map m_po;
Expand Down
3 changes: 2 additions & 1 deletion playdar-daemon/src/application/appsettings.h
Expand Up @@ -80,7 +80,8 @@ class SettingsManager
}

private:
map< string, string > m_settings;
// category -> key -> value
map< string, map< string, string > > m_settings;
string m_filename;

// if rewrite, will replace config with existing settings in m_settings
Expand Down

0 comments on commit 9f2efc0

Please sign in to comment.