Fraxinus  18.10
An IGT application
cxDataFactory.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxDataFactory.h"
13 
14 #include "cxImage.h"
15 #include "cxMesh.h"
16 #include "cxTrackedStream.h"
17 #include "cxPointMetric.h"
18 #include "cxDistanceMetric.h"
19 #include "cxPlaneMetric.h"
20 #include "cxAngleMetric.h"
21 #include "cxShapedMetric.h"
22 #include "cxCustomMetric.h"
23 #include "cxSphereMetric.h"
24 #include "cxFrameMetric.h"
25 #include "cxToolMetric.h"
27 
28 #include "cxPatientModelService.h"
29 
30 
31 namespace cx
32 {
33 
35  mDataManager(dataManager),
36  mSpaceProvider(spaceProvider)
37 {
38 
39 }
40 
41 #define CREATE_IF_MATCH(typeName, TYPE) \
42 { \
43  if (typeName==TYPE::getTypeName()) \
44  return TYPE::create(uid, ""); \
45 }
46 #define CREATE_WITH_SERVICES_IF_MATCH(typeName, TYPE) \
47 { \
48  if (typeName==TYPE::getTypeName()) \
49  return TYPE::create(uid, "", mDataManager, mSpaceProvider); \
50 }
51 
52 DataPtr DataFactory::createRaw(QString type, QString uid)
53 {
54  CREATE_IF_MATCH(type, Image);
55  CREATE_IF_MATCH(type, TrackedStream);
57  CREATE_WITH_SERVICES_IF_MATCH(type, PointMetric);
58  CREATE_WITH_SERVICES_IF_MATCH(type, PlaneMetric);
59  CREATE_WITH_SERVICES_IF_MATCH(type, DistanceMetric);
60  CREATE_WITH_SERVICES_IF_MATCH(type, AngleMetric);
61  CREATE_WITH_SERVICES_IF_MATCH(type, FrameMetric);
62  CREATE_WITH_SERVICES_IF_MATCH(type, ToolMetric);
63  CREATE_WITH_SERVICES_IF_MATCH(type, DonutMetric);
64  CREATE_WITH_SERVICES_IF_MATCH(type, CustomMetric);
65  CREATE_WITH_SERVICES_IF_MATCH(type, SphereMetric);
66  CREATE_WITH_SERVICES_IF_MATCH(type, RegionOfInterestMetric);
67  return DataPtr ();
68 }
69 
70 DataPtr DataFactory::create(QString type, QString uid, QString name)
71 {
72  DataPtr retval = this->createRaw(type, uid);
73  if (name.isEmpty())
74  name = uid;
75  if (retval)
76  retval->setName(name);
77  return retval;
78 }
79 
80 } // namespace cx
81 
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
#define CREATE_IF_MATCH(typeName, TYPE)
DataPtr create(QString type, QString uid, QString name="")
#define CREATE_WITH_SERVICES_IF_MATCH(typeName, TYPE)
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
DataFactory(PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider)
Namespace for all CustusX production code.