Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxCommandlineImageStreamerFactory.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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
34 
35 #include "cxLogger.h"
36 #include "cxImageStreamerOpenCV.h"
37 #include "cxMHDImageStreamer.h"
38 #include "cxImageStreamerSonix.h"
39 #include "cxConfig.h"
40 
41 namespace cx
42 {
43 
45 {
46  StringMap retval;
47 
48  for (int i = 0; i < cmdline.size(); ++i)
49  {
50  if (!cmdline[i].startsWith("--"))
51  continue;
52  QString name, val;
53  name = cmdline[i].remove(0, 2);
54  if (i + 1 < cmdline.size())
55  val = cmdline[i + 1];
56  retval[name] = val;
57  }
58 
59  return retval;
60 }
61 
62 
66 
68 {
69  QString type = this->getDefaultSenderType();
70  if (args.count("type"))
71  type = args["type"];
72 
73  CommandLineStreamerPtr streamer = this->getImageSender(type);
74 
75  if (streamer)
76  reportSuccess("Created sender of type: "+type);
77  else
78  {
79  reportError("Failed to create sender based on type: "+type);
80  return streamer;
81  }
82 
83  streamer->initialize(args);
84  return streamer;
85 }
86 
87 
89 {
90 #ifdef CX_USE_OpenCV
91  mCommandLineStreamers.push_back(CommandLineStreamerPtr(new ImageStreamerOpenCV()));
92 #endif
93  mCommandLineStreamers.push_back(DummyImageStreamerPtr(new DummyImageStreamer()));
94 }
95 
97 {
98  return this->getSenderTypes().front();
99 }
100 
102 {
103  QStringList retval;
104  for (unsigned i=0; i< mCommandLineStreamers.size(); ++i)
105  retval << mCommandLineStreamers[i]->getType();
106  return retval;
107 }
108 
110 {
111  for (unsigned i=0; i< mCommandLineStreamers.size(); ++i)
112  if (mCommandLineStreamers[i]->getType()==type)
113  return mCommandLineStreamers[i]->getArgumentDescription();
114  return QStringList();
115 }
116 
118 {
119  for (unsigned i=0; i< mCommandLineStreamers.size(); ++i)
120  if (mCommandLineStreamers[i]->getType()==type)
121  return mCommandLineStreamers[i];
122  return CommandLineStreamerPtr();
123 }
124 
125 
126 }
void reportError(QString msg)
Definition: cxLogger.cpp:92
QStringList getSenderTypes() const
all available sender types
CommandLineStreamerPtr getImageSender(QString type)
std::map< QString, QString > StringMap
void reportSuccess(QString msg)
Definition: cxLogger.cpp:93
QStringList getArgumentDescription(QString type) const
arguments for one streamer
StringMap extractCommandlineOptions(QStringList cmdline)
boost::shared_ptr< class DummyImageStreamer > DummyImageStreamerPtr
boost::shared_ptr< CommandLineStreamer > CommandLineStreamerPtr
Definition: cxStreamer.h:124
boost::shared_ptr< class Streamer > StreamerPtr