gdcmCSAElement.h
Go to the documentation of this file.
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef GDCMCSAELEMENT_H
#define GDCMCSAELEMENT_H
#include "gdcmTag.h"
#include "gdcmVM.h"
#include "gdcmVR.h"
#include "gdcmByteValue.h"
#include "gdcmSmartPointer.h"
namespace gdcm
{
class GDCM_EXPORT CSAElement
{
public:
CSAElement(unsigned int kf = 0):KeyField(kf) {}
friend std::ostream& operator<<(std::ostream &os, const CSAElement &val);
unsigned int GetKey() const { return KeyField; }
void SetKey(unsigned int key) { KeyField = key; }
const char *GetName() const { return NameField.c_str(); }
void SetName(const char *name) { NameField = name; }
const VM& GetVM() const { return ValueMultiplicityField; }
void SetVM(const VM &vm) { ValueMultiplicityField = vm; }
VR const &GetVR() const { return VRField; }
void SetVR(VR const &vr) { VRField = vr; }
unsigned int GetSyngoDT() const { return SyngoDTField; }
void SetSyngoDT(unsigned int syngodt) { SyngoDTField = syngodt; }
unsigned int GetNoOfItems() const { return NoOfItemsField; }
void SetNoOfItems(unsigned int items) { NoOfItemsField = items; }
Value const &GetValue() const { return *DataField; }
Value &GetValue() { return *DataField; }
void SetValue(Value const & vl) {
//assert( DataField == 0 );
DataField = vl;
}
bool IsEmpty() const { return DataField == nullptr; }
void SetByteValue(const char *array, VL length)
{
ByteValue *bv = new ByteValue(array,length);
SetValue( *bv );
}
const ByteValue* GetByteValue() const {
// Get the raw pointer from the gdcm::SmartPointer
const ByteValue *bv = dynamic_cast<const ByteValue*>(DataField.GetPointer());
return bv; // Will return NULL if not ByteValue
}
CSAElement(const CSAElement &_val)
{
if( this != &_val)
{
*this = _val;
}
}
bool operator<(const CSAElement &de) const
{
return GetKey() < de.GetKey();
}
CSAElement &operator=(const CSAElement &de)
= default;
bool operator==(const CSAElement &de) const
{
return KeyField == de.KeyField
&& NameField == de.NameField
&& ValueMultiplicityField == de.ValueMultiplicityField
&& VRField == de.VRField
&& SyngoDTField == de.SyngoDTField
//&& ValueField == de.ValueField;
;
}
protected:
unsigned int KeyField;
std::string NameField;
VM ValueMultiplicityField;
VR VRField;
unsigned int SyngoDTField;
unsigned int NoOfItemsField;
typedef SmartPointer<Value> DataPtr;
DataPtr DataField;
};
//-----------------------------------------------------------------------------
inline std::ostream& operator<<(std::ostream &os, const CSAElement &val)
{
os << val.KeyField;
os << " - '" << val.NameField;
os << "' VM " << val.ValueMultiplicityField;
os << ", VR " << val.VRField;
os << ", SyngoDT " << val.SyngoDTField;
os << ", NoOfItems " << val.NoOfItemsField;
os << ", Data ";
if( val.DataField )
{
//val.DataField->Print( os << "'" );
const ByteValue * bv = dynamic_cast<ByteValue*>(&*val.DataField);
assert( bv );
const char * p = bv->GetPointer();
std::string str(p, p + bv->GetLength() );
if( val.ValueMultiplicityField == VM::VM1 )
{
os << "'" << str.c_str() << "'";
}
else
{
std::istringstream is( str );
std::string s;
bool sep = false;
while( std::getline(is, s, '\\' ) )
{
if( sep )
{
os << '\\';
}
sep = true;
os << "'" << s.c_str() << "'";
}
//bv->Print( os << "'" );
//os << "'";
}
}
return os;
}
} // end namespace gdcm
#endif //GDCMCSAELEMENT_H
gdcm::ByteValue
Class to represent binary value (array of bytes).
Definition gdcmByteValue.h:35
gdcm::ByteValue::GetPointer
const char * GetPointer() const
Definition gdcmByteValue.h:110
gdcm::ByteValue::GetLength
VL GetLength() const override
Definition gdcmByteValue.h:77
gdcm::CSAElement
Class to represent a CSA Element.
Definition gdcmCSAElement.h:30
gdcm::CSAElement::SetValue
void SetValue(Value const &vl)
Definition gdcmCSAElement.h:63
gdcm::CSAElement::GetSyngoDT
unsigned int GetSyngoDT() const
Set/Get SyngoDT.
Definition gdcmCSAElement.h:53
gdcm::CSAElement::NameField
std::string NameField
Definition gdcmCSAElement.h:112
gdcm::CSAElement::operator==
bool operator==(const CSAElement &de) const
Definition gdcmCSAElement.h:99
gdcm::CSAElement::GetByteValue
const ByteValue * GetByteValue() const
Definition gdcmCSAElement.h:78
gdcm::CSAElement::SyngoDTField
unsigned int SyngoDTField
Definition gdcmCSAElement.h:115
gdcm::CSAElement::operator<
bool operator<(const CSAElement &de) const
Definition gdcmCSAElement.h:92
gdcm::CSAElement::SetNoOfItems
void SetNoOfItems(unsigned int items)
Definition gdcmCSAElement.h:58
gdcm::CSAElement::operator=
CSAElement & operator=(const CSAElement &de)=default
gdcm::CSAElement::SetSyngoDT
void SetSyngoDT(unsigned int syngodt)
Definition gdcmCSAElement.h:54
gdcm::CSAElement::ValueMultiplicityField
VM ValueMultiplicityField
Definition gdcmCSAElement.h:113
gdcm::CSAElement::GetName
const char * GetName() const
Set/Get Name.
Definition gdcmCSAElement.h:41
gdcm::CSAElement::KeyField
unsigned int KeyField
Definition gdcmCSAElement.h:111
gdcm::CSAElement::SetByteValue
void SetByteValue(const char *array, VL length)
Set.
Definition gdcmCSAElement.h:71
gdcm::CSAElement::DataPtr
SmartPointer< Value > DataPtr
Definition gdcmCSAElement.h:117
gdcm::CSAElement::CSAElement
CSAElement(unsigned int kf=0)
Definition gdcmCSAElement.h:32
gdcm::CSAElement::IsEmpty
bool IsEmpty() const
Check if CSA Element is empty.
Definition gdcmCSAElement.h:68
gdcm::CSAElement::GetVR
VR const & GetVR() const
Set/Get VR.
Definition gdcmCSAElement.h:49
gdcm::CSAElement::SetVR
void SetVR(VR const &vr)
Definition gdcmCSAElement.h:50
gdcm::CSAElement::VRField
VR VRField
Definition gdcmCSAElement.h:114
gdcm::CSAElement::NoOfItemsField
unsigned int NoOfItemsField
Definition gdcmCSAElement.h:116
gdcm::CSAElement::GetValue
Value & GetValue()
Definition gdcmCSAElement.h:62
gdcm::CSAElement::CSAElement
CSAElement(const CSAElement &_val)
Definition gdcmCSAElement.h:84
gdcm::CSAElement::GetNoOfItems
unsigned int GetNoOfItems() const
Set/Get NoOfItems.
Definition gdcmCSAElement.h:57
gdcm::CSAElement::GetVM
const VM & GetVM() const
Set/Get VM.
Definition gdcmCSAElement.h:45
gdcm::CSAElement::GetKey
unsigned int GetKey() const
Set/Get Key.
Definition gdcmCSAElement.h:37
gdcm::CSAElement::DataField
DataPtr DataField
Definition gdcmCSAElement.h:118
gdcm::CSAElement::SetName
void SetName(const char *name)
Definition gdcmCSAElement.h:42
gdcm::CSAElement::GetValue
Value const & GetValue() const
Set/Get Value (bytes array, SQ of items, SQ of fragments):
Definition gdcmCSAElement.h:61
gdcm::CSAElement::SetKey
void SetKey(unsigned int key)
Definition gdcmCSAElement.h:38
gdcm::CSAElement::SetVM
void SetVM(const VM &vm)
Definition gdcmCSAElement.h:46
gdcm::SmartPointer
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
gdcm::VL
Value Length.
Definition gdcmVL.h:30
gdcm::VM
Value Multiplicity Looking at the DICOMV3 dict only there is very few cases: 1 2 3 4 5 6 8 16 24 1-2 ...
Definition gdcmVM.h:68
gdcm::VM::VM1
@ VM1
Definition gdcmVM.h:72
gdcm::VR
VR class.
Definition gdcmVR.h:55
gdcm::Value
Class to represent the value of a Data Element.
Definition gdcmValue.h:32
gdcmByteValue.h
gdcmSmartPointer.h
gdcmTag.h
gdcmVM.h
gdcmVR.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21
gdcm::operator<<
std::ostream & operator<<(std::ostream &os, const Directory &d)
Definition gdcmDirectory.h:88