DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Public Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Protocol.DefaultLocalBootable Class Reference

A bootable object that filters through to a DatabaseInterface but is thread-safe and multi-threaded. /summary> More...

Inheritance diagram for Deveel.Data.Protocol.DefaultLocalBootable:
Deveel.Data.IDatabaseHandler

Classes

class  LocalDatabaseInterface
 A local implementation of DatabaseInterface that will dispose the parent ILocalBootable object when the last open connection is disposed. More...
 

Public Member Functions

 DefaultLocalBootable (DbController controller, string databaseName)
 
IDatabaseInterface Create (string username, string password, IDbConfig config)
 
IDatabaseInterface Boot (IDbConfig config)
 
bool CheckExists (IDbConfig config)
 
IDatabaseInterface Connect ()
 

Properties

bool IsBooted [get]
 

Private Member Functions

IDatabase IDatabaseHandler. GetDatabase (string name)
 

Private Attributes

readonly DbController controller
 
readonly string databaseName
 
bool booted
 Set to true if the database is booted. More...
 
Control.DbSystem dbsys
 The local DbSystem database object. More...
 
int connectId
 The connection id. More...
 
int openConnections
 The number of connections that are current open. More...
 

Detailed Description

A bootable object that filters through to a DatabaseInterface but is thread-safe and multi-threaded. /summary>

This is to be used when you have a local client accessing a stand-alone database.

Definition at line 31 of file DefaultLocalBootable.cs.

Constructor & Destructor Documentation

Deveel.Data.Protocol.DefaultLocalBootable.DefaultLocalBootable ( DbController  controller,
string  databaseName 
)
inline

Definition at line 32 of file DefaultLocalBootable.cs.

Member Function Documentation

IDatabaseInterface Deveel.Data.Protocol.DefaultLocalBootable.Boot ( IDbConfig  config)
inline

Definition at line 93 of file DefaultLocalBootable.cs.

93  {
94  if (booted)
95  throw new DataException("Database was booted more than once.");
96 
97  // Local connections are formatted as;
98  // 'Local/[type]/[connect_id]'
99  string hostString = String.Format("{0}/Boot/", KnownConnectionProtocols.Local);
100 
101  // Start the DbSystem and bind it to a IDatabaseInterface.
102  if (controller.IsInitialized(databaseName))
103  dbsys = controller.ConnectToDatabase(config, databaseName);
104  else
105  dbsys = controller.StartDatabase(config, databaseName);
106 
107  IDatabaseInterface dbInterface = new LocalDatabaseInterface(this, hostString);
108 
109  booted = true;
110  ++openConnections;
111 
112  return dbInterface;
113  }
A long string in the system.
bool booted
Set to true if the database is booted.
Control.DbSystem dbsys
The local DbSystem database object.
int openConnections
The number of connections that are current open.
bool Deveel.Data.Protocol.DefaultLocalBootable.CheckExists ( IDbConfig  config)
inline

Definition at line 116 of file DefaultLocalBootable.cs.

116  {
117  if (booted)
118  throw new DataException("The database is already booted.");
119 
120  return controller.DatabaseExists(config, databaseName);
121  }
bool booted
Set to true if the database is booted.
IDatabaseInterface Deveel.Data.Protocol.DefaultLocalBootable.Connect ( )
inline

Definition at line 129 of file DefaultLocalBootable.cs.

129  {
130  if (!booted)
131  throw new DataException("The database is not started.");
132 
133  // Local connections are formatted as;
134  // 'Local/[type]/[connect_id]'
135  string hostString = String.Format("{0}/Connection/{1}", KnownConnectionProtocols.Local, connectId);
136 
137  // Create a IDatabaseInterface,
138  IDatabaseInterface dbInterface = new LocalDatabaseInterface(this, hostString);
139 
140  ++connectId;
141  ++openConnections;
142 
143  return dbInterface;
144  }
A long string in the system.
bool booted
Set to true if the database is booted.
int openConnections
The number of connections that are current open.
IDatabaseInterface Deveel.Data.Protocol.DefaultLocalBootable.Create ( string  username,
string  password,
IDbConfig  config 
)
inline

Definition at line 65 of file DefaultLocalBootable.cs.

65  {
66  if (String.IsNullOrEmpty(username) ||
67  String.IsNullOrEmpty(password))
68  throw new DataException("Username and Password must both be set.");
69 
70  if (booted)
71  throw new DataException("Database is already created.");
72 
73  // Local connections are formatted as;
74  // 'Local/[type]/[connect_id]'
75  string hostString = String.Format("{0}/Create/", KnownConnectionProtocols.Local);
76 
77  // Create the DbSystem and bind it to a IDatabaseInterface.
78  dbsys = controller.CreateDatabase(config, databaseName, username, password);
79  IDatabaseInterface dbInterface = new LocalDatabaseInterface(this, hostString);
80 
81  booted = true;
83 
84  return dbInterface;
85  }
A long string in the system.
bool booted
Set to true if the database is booted.
Control.DbSystem dbsys
The local DbSystem database object.
int openConnections
The number of connections that are current open.
IDatabase IDatabaseHandler. Deveel.Data.Protocol.DefaultLocalBootable.GetDatabase ( string  name)
inlineprivate

Implements Deveel.Data.IDatabaseHandler.

Definition at line 88 of file DefaultLocalBootable.cs.

88  {
89  return (dbsys == null ? null : dbsys.Database);
90  }
Control.DbSystem dbsys
The local DbSystem database object.

Member Data Documentation

bool Deveel.Data.Protocol.DefaultLocalBootable.booted
private

Set to true if the database is booted.

Definition at line 43 of file DefaultLocalBootable.cs.

int Deveel.Data.Protocol.DefaultLocalBootable.connectId
private

The connection id.

This is incremented by 1 each time an interface connects to the local runtime.

Definition at line 57 of file DefaultLocalBootable.cs.

readonly DbController Deveel.Data.Protocol.DefaultLocalBootable.controller
private

Definition at line 37 of file DefaultLocalBootable.cs.

readonly string Deveel.Data.Protocol.DefaultLocalBootable.databaseName
private

Definition at line 38 of file DefaultLocalBootable.cs.

Control.DbSystem Deveel.Data.Protocol.DefaultLocalBootable.dbsys
private

The local DbSystem database object.

Definition at line 48 of file DefaultLocalBootable.cs.

int Deveel.Data.Protocol.DefaultLocalBootable.openConnections
private

The number of connections that are current open.

Definition at line 62 of file DefaultLocalBootable.cs.

Property Documentation

bool Deveel.Data.Protocol.DefaultLocalBootable.IsBooted
get

Definition at line 124 of file DefaultLocalBootable.cs.


The documentation for this class was generated from the following file: