Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 57 lines (42 sloc) 1.489 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
// Copyright 2011 Heath Schultz et. al. under liberal licenses. See LICENSE for details.

#ifndef RESOURCES_H
#define RESOURCES_H

// Pass an object around that refers to all of our resources such as
// json and db so that we don't have to pass references for everything

#include "sqlitedb.h"
#include "json.h"
#include "keyvals.h"

template<typename T> class resources_t {

public:

resources_t(json_interface & tempjson, sqlite3_db & tempdb) : \
current_identity() , \
current_buddy() , \
json(tempjson) , \
db(tempdb) , \
inbound_mode(0) { }

const int get_inbound_mode() {
return atoi(Get(db, "inbound_mode").c_str());
}

void set_inbound_mode(const int & tempmode) {
std::stringstream modestream;
modestream << tempmode;
Set(db, "inbound_mode", modestream.str());
}

// void set_inbound_mode(const int & tempmode) {
// inbound_mode = tempmode;
// std::stringstream modestream;
// modestream << inbound_mode;
// Set(db, "inbound_mode", );
// }

json_interface & get_json_interface() { return json; }
sqlite3_db & get_db() { return db; }
string & get_current_identity() { return current_identity; }
string & get_current_buddy() { return current_buddy; }

private:

string current_identity;
string current_buddy;
json_interface & json;
sqlite3_db & db;
int inbound_mode;

}; typedef resources_t<int> resources;

#endif
Something went wrong with that request. Please try again.