Nebula
Loading...
Searching...
No Matches
dataset.h
Go to the documentation of this file.
1#pragma once
2#ifndef DB_DATASET_H
3#define DB_DATASET_H
4//------------------------------------------------------------------------------
31#include "core/refcounted.h"
32#include "db/filterset.h"
33#include "db/valuetable.h"
34#include "db/relation.h"
35
36//------------------------------------------------------------------------------
37namespace Db
38{
39class Database;
40class Table;
41
43{
45public:
47 Dataset();
49 virtual ~Dataset();
50
52 void AddColumn(const Attr::AttrId& attrId);
54 void AddAllTableColumns();
56 const Ptr<Table>& GetTable() const;
58 const Ptr<FilterSet>& Filter();
60 const Ptr<ValueTable>& Values();
61
63 virtual void PerformQuery(bool appendResult=false);
65 virtual void CommitChanges(bool newRowsAsUpdate=false);
67 virtual void CommitDeletedRows();
68
69protected:
70 friend class Table;
71
73 void SetTable(const Ptr<Table>& t);
75 virtual bool Connect();
77 virtual void Disconnect();
79 bool IsConnected() const;
80
85};
86
87//------------------------------------------------------------------------------
90inline void
92{
93 n_assert(0 != t);
94 this->table = t;
95}
96
97//------------------------------------------------------------------------------
100inline const Ptr<Table>&
102{
103 return this->table;
104}
105
106//------------------------------------------------------------------------------
109inline bool
111{
112 return this->isConnected;
113}
114
115//------------------------------------------------------------------------------
118inline const Ptr<FilterSet>&
120{
121 return this->filter;
122}
123
124//------------------------------------------------------------------------------
127inline const Ptr<ValueTable>&
129{
130 return this->values;
131}
132
133} // namespace Db
134//------------------------------------------------------------------------------
135#endif
An attribute ID is used to carry attribute types (no values) around.
Definition attrid.h:20
The common base class of Nebula.
Definition refcounted.h:38
A dataset is an efficient in-memory-cache for rlational database data.
Definition dataset.h:43
virtual void PerformQuery(bool appendResult=false)
fill value table from database
Definition dataset.cc:106
Ptr< Table > table
Definition dataset.h:82
virtual void Disconnect()
disconnect from database table
Definition dataset.cc:87
Ptr< FilterSet > filter
Definition dataset.h:83
const Ptr< Table > & GetTable() const
get pointer to database table this set is associated with
Definition dataset.h:101
void SetTable(const Ptr< Table > &t)
set pointer to database table
Definition dataset.h:91
virtual void CommitDeletedRows()
commit deleted rows only to the database
Definition dataset.cc:132
Dataset()
constructor
Definition dataset.cc:18
const Ptr< ValueTable > & Values()
access to value table
Definition dataset.h:128
const Ptr< FilterSet > & Filter()
access to query filter
Definition dataset.h:119
virtual bool Connect()
connect to database table
Definition dataset.cc:70
__DeclareClass(Dataset)
Ptr< ValueTable > values
Definition dataset.h:84
virtual void CommitChanges(bool newRowsAsUpdate=false)
commit modified values to the database
Definition dataset.cc:121
bool isConnected
Definition dataset.h:81
bool IsConnected() const
return true if the dataset is connected
Definition dataset.h:110
void AddAllTableColumns()
add all the table columns to the dataset
Definition dataset.cc:49
virtual ~Dataset()
destructor
Definition dataset.cc:28
void AddColumn(const Attr::AttrId &attrId)
add the columns you're interested in
Definition dataset.cc:37
Describes a table in a database, or more abstract, a set of typed columns grouped under a common name...
Definition table.h:34
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
#define n_assert(exp)
Definition debug.h:50
Definition column.cc:10