CustusX  22.04-rc5
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 #include "cxPatientModelService.h"
28 #include "cxLogger.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  CX_LOG_WARNING() << "DataFactory::createRaw - No match for type: " << type;
68  return DataPtr ();
69 }
70 
71 DataPtr DataFactory::create(QString type, QString uid, QString name)
72 {
73  DataPtr retval = this->createRaw(type, uid);
74  if (name.isEmpty())
75  name = uid;
76  if (retval)
77  retval->setName(name);
78  return retval;
79 }
80 
81 } // namespace cx
82 
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)
#define CX_LOG_WARNING
Definition: cxLogger.h:98
Namespace for all CustusX production code.