-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathAnnotationService.cpp
More file actions
71 lines (63 loc) · 1.73 KB
/
AnnotationService.cpp
File metadata and controls
71 lines (63 loc) · 1.73 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
63
64
65
66
67
68
69
70
71
#include "AnnotationService.h"
#include "AnnotationList.h"
#include "XmlRepository.h"
#include "NDPARepository.h"
#include "ImageScopeRepository.h"
AnnotationService::AnnotationService() :
_list(NULL),
_repo(NULL)
{
_list = std::make_shared<AnnotationList>();
}
AnnotationService::~AnnotationService() {
}
std::shared_ptr<AnnotationList> AnnotationService::getList() const {
return _list;
}
std::shared_ptr<Repository> AnnotationService::getRepository() const {
return _repo;
}
bool AnnotationService::loadRepositoryFromFile(const std::string& source) {
if (source.rfind(std::string(".xml")) != source.npos) {
_repo = std::make_shared<XmlRepository>(_list);
_repo->setSource(source);
if (!_repo->load()) {
_list->removeAllAnnotations();
_list->removeAllGroups();
_repo = std::make_shared<ImageScopeRepository>(_list);
_repo->setSource(source);
}
}
else if (source.rfind(std::string(".ndpa")) != source.npos) {
_repo = std::make_shared<NDPARepository>(_list);
_repo->setSource(source);
}
return _repo->load();
}
bool AnnotationService::saveRepositoryToFile(const std::string& source) {
if (source.rfind(std::string(".xml")) != source.npos) {
_repo = std::make_shared<XmlRepository>(_list);
_repo->setSource(source);
}
else if (source.rfind(std::string(".ndpa")) != source.npos) {
_repo = std::make_shared<NDPARepository>(_list);
_repo->setSource(source);
}
return _repo->save();
}
bool AnnotationService::load() {
if (_repo) {
return _repo->load();
}
else {
return false;
}
}
bool AnnotationService::save() {
if (_repo) {
return _repo->save();
}
else {
return false;
}
}