Magick++  7.1.0
CoderInfo.cpp
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 2001, 2002
4 //
5 // Copyright @ 2013 ImageMagick Studio LLC, a non-profit organization
6 // dedicated to making software imaging solutions freely available.
7 //
8 // CoderInfo implementation
9 //
10 
11 #define MAGICKCORE_IMPLEMENTATION 1
12 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
13 
14 #include "Magick++/Include.h"
15 #include "Magick++/CoderInfo.h"
16 #include "Magick++/Exception.h"
17 
18 using namespace std;
19 
21  : _decoderThreadSupport(false),
22  _description(),
23  _encoderThreadSupport(false),
24  _isMultiFrame(false),
25  _isReadable(false),
26  _isWritable(false),
27  _mimeType(),
28  _module(),
29  _name()
30 {
31 }
32 
34  : _decoderThreadSupport(coder_._decoderThreadSupport),
35  _description(coder_._description),
36  _encoderThreadSupport(coder_._encoderThreadSupport),
37  _isMultiFrame(coder_._isMultiFrame),
38  _isReadable(coder_._isReadable),
39  _isWritable(coder_._isWritable),
40  _mimeType(coder_._mimeType),
41  _module(coder_._module),
42  _name(coder_._name)
43 {
44 }
45 
46 Magick::CoderInfo::CoderInfo(const std::string &name_)
47  : _decoderThreadSupport(false),
48  _description(),
49  _encoderThreadSupport(false),
50  _isMultiFrame(false),
51  _isReadable(false),
52  _isWritable(false),
53  _mimeType(),
54  _module(),
55  _name()
56 {
57  const Magick::MagickInfo
58  *magickInfo;
59 
61  magickInfo=GetMagickInfo(name_.c_str(),exceptionInfo);
62  ThrowPPException(false);
63  if (magickInfo == 0)
64  throwExceptionExplicit(MagickCore::OptionError,"Coder not found",
65  name_.c_str());
66  else
67  {
68  _decoderThreadSupport=(GetMagickDecoderThreadSupport(magickInfo) ==
69  MagickTrue) ? true : false;
70  _description=std::string(magickInfo->description);
71  _encoderThreadSupport=(GetMagickEncoderThreadSupport(magickInfo) ==
72  MagickTrue) ? true : false;
73  _isMultiFrame=(GetMagickAdjoin(magickInfo) == MagickTrue) ? true : false;
74  _isReadable=((magickInfo->decoder == (MagickCore::DecodeImageHandler *)
75  NULL) ? false : true);
76  _isWritable=((magickInfo->encoder == (MagickCore::EncodeImageHandler *)
77  NULL) ? false : true);
78  _mimeType=std::string(magickInfo->mime_type != (char *) NULL ?
79  magickInfo->mime_type : "");
80  _module=std::string(magickInfo->magick_module);
81  _name=std::string(magickInfo->name);
82  }
83 }
84 
86 {
87 }
88 
90 {
91  // If not being set to ourself
92  if (this != &coder_)
93  {
94  _decoderThreadSupport=coder_._decoderThreadSupport;
95  _description=coder_._description;
96  _encoderThreadSupport=coder_._encoderThreadSupport;
97  _isMultiFrame=coder_._isMultiFrame;
98  _isReadable=coder_._isReadable;
99  _isWritable=coder_._isWritable;
100  _mimeType=coder_._mimeType;
101  _module=coder_._module;
102  _name=coder_._name;
103  }
104  return(*this);
105 }
106 
108 {
109  return(_decoderThreadSupport);
110 }
111 
113 {
114  return(_encoderThreadSupport);
115 }
116 
117 std::string Magick::CoderInfo::description(void) const
118 {
119  return(_description);
120 }
121 
123 {
124  return(_isReadable);
125 }
126 
128 {
129  return(_isWritable);
130 }
131 
133 {
134  return(_isMultiFrame);
135 }
136 
137 std::string Magick::CoderInfo::mimeType(void) const
138 {
139  return(_mimeType);
140 }
141 
142 std::string Magick::CoderInfo::module(void) const
143 {
144  return(_module);
145 }
146 
147 std::string Magick::CoderInfo::name(void) const
148 {
149  return(_name);
150 }
151 
153 {
154  return(UnregisterMagickInfo(_name.c_str()) != MagickFalse);
155 }
CoderInfo & operator=(const CoderInfo &coder_)
Definition: CoderInfo.cpp:89
bool isReadable(void) const
Definition: CoderInfo.cpp:122
STL namespace.
bool unregister(void) const
Definition: CoderInfo.cpp:152
bool canWriteMultithreaded(void) const
Definition: CoderInfo.cpp:112
bool isMultiFrame(void) const
Definition: CoderInfo.cpp:132
std::string description(void) const
Definition: CoderInfo.cpp:117
MagickPPExport void throwExceptionExplicit(const MagickCore::ExceptionType severity_, const char *reason_, const char *description_=(char *) NULL)
Definition: Exception.cpp:808
#define ThrowPPException(quiet)
Definition: Include.h:1580
std::string mimeType(void) const
Definition: CoderInfo.cpp:137
std::string module(void) const
Definition: CoderInfo.cpp:142
bool isWritable(void) const
Definition: CoderInfo.cpp:127
bool canReadMultithreaded(void) const
Definition: CoderInfo.cpp:107
#define GetPPException
Definition: Include.h:1561
std::string name(void) const
Definition: CoderInfo.cpp:147