-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionFactory.cpp
More file actions
62 lines (47 loc) · 1.44 KB
/
SessionFactory.cpp
File metadata and controls
62 lines (47 loc) · 1.44 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
57
58
59
60
61
62
#include "stdafx.h"
#include "SessionFactory.h"
#include "Session.h"
#include "SqlExecutor.h"
#include "SqlServerDialect.h"
void orm::swap(SessionFactory &left, SessionFactory &right)
{
using std::swap;
swap(left._configuration, right._configuration);
swap(left._environment, right._environment);
}
orm::SessionFactory::SessionFactory()
{
}
orm::SessionFactory::SessionFactory(const std::shared_ptr<odbc::environment> &environment, const SessionFactoryConfiguration &configuration) :
_environment(environment)
, _configuration(configuration)
{
}
orm::SessionFactory::SessionFactory(const SessionFactory &other) :
_environment(other._environment)
, _configuration(other._configuration)
{
}
orm::SessionFactory::SessionFactory(SessionFactory &&other) :
SessionFactory()
{
swap(*this, other);
}
orm::SessionFactory::~SessionFactory()
{
}
orm::SessionFactory &orm::SessionFactory::operator =(SessionFactory other)
{
swap(*this, other);
return *this;
}
orm::session orm::SessionFactory::Open() const
{
std::string connectionString = _configuration.BuildConnectionString();
const MappingRegistry ®istry = _configuration.GetMappingRegistry();
// TODO: allow this to be configurable...somehow
std::shared_ptr<ISqlDialect> dialect = std::make_shared<SqlServerDialect>();
std::shared_ptr<ISqlExecutor> executor = std::make_shared<SqlExecutor>();
orm::session result(_environment, connectionString, dialect, executor, registry);
return result;
}