ALBA
albaTagItem.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: ALBA (Agile Library for Biomedical Applications)
4 Module: albaTagItem
5 Authors: Marco Petrone
6
7 Copyright (c) BIC
8 All rights reserved. See Copyright.txt or
9
10
11 This software is distributed WITHOUT ANY WARRANTY; without even
12 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE. See the above copyright notice for more information.
14
15=========================================================================*/
16#ifndef __albaTagItem_h
17#define __albaTagItem_h
18//----------------------------------------------------------------------------
19// includes :
20//----------------------------------------------------------------------------
21#include "albaUtility.h"
22#include "albaStorable.h"
23#include "albaString.h"
24#include <vector>
25#include <string>
26#include <iosfwd>
27
28#ifdef ALBA_EXPORTS
29#include "albaDllMacros.h"
30EXPORT_STL_VECTOR(ALBA_EXPORT,albaString);
31#endif
32
33//----------------------------------------------------------------------------
34// constants
35//----------------------------------------------------------------------------
37
38//----------------------------------------------------------------------------
39// forward declarations
40//----------------------------------------------------------------------------
41
46class ALBA_EXPORT albaTagItem : public albaUtility, public albaStorable
47{
48public:
51
53 albaTagItem(const char *name, const char *value, int t=ALBA_STRING_TAG);
54 albaTagItem(const char *name, const char **values, int numcomp, int t=ALBA_STRING_TAG);
55 albaTagItem(const char *name, const std::vector<albaString> &values, int numcomp, int t=ALBA_STRING_TAG);
56 albaTagItem(const char *name, const double value);
57 albaTagItem(const char *name, const double *value, int numcomp);
58 albaTagItem(const char *name, const std::vector<double> &values, int numcomp);
59
61 void operator=(const albaTagItem& p);
62
63 bool operator==(const albaTagItem& p) const;
64 bool operator!=(const albaTagItem& p) const;
65
66 virtual void Print(std::ostream& os, const int indent=0) const;
67
69 void SetName(const char *name);
70 const char *GetName() const;
71
75 void SetValue(const albaString value,int component=0);
77 void SetComponent(const albaString value,int component=0);
78
80 void SetValue(const double value , int component=0);
82 void SetComponent(const double value , int component=0);
83
85 void SetComponents(const char **values, int numcomp);
87 void SetComponents(const std::vector<albaString> components);
88
90 void SetValues(const std::vector<albaString> values);
92 void SetValues(const char **values, int numcomp);
93
95 void RemoveValue(int component); //Added by Mucci 22/10/2007
96
98 void SetValues(const double *values, int numcomp);
100 void SetValues(const std::vector<double> values);
101
103 void SetComponents(const double *components, int numcomp);
104
106 void SetComponents(const std::vector<double> components);
107
112 const char *GetValue(int component=0) const;
113
115 const char *GetComponent(int comp) const;
116
118 double GetValueAsDouble(int component=0) const;
119 double GetComponentAsDouble(int comp) const;
120
122 const std::vector<albaString> *GetComponents() const {return &m_Components;};
123
125 std::vector<double> GetComponentsAsDoubles() const;;
126
127
133 void GetValueAsSingleString(std::string &str) const;
134
135
140 void SetType (int t) {m_Type=t;};
141
146 int GetType() const {return m_Type;};
147
153 void GetTypeAsString(albaString &value) const;
154 void GetTypeAsString(std::string &value) const;
155
162
164 bool Equals(const albaTagItem *item) const;
165
167 void DeepCopy(const albaTagItem *item);
168
169protected:
170 virtual int InternalStore(albaStorageElement *parent);
172
174
177 std::vector<albaString> m_Components;
178};
179
180#endif
181
#define EXPORT_STL_VECTOR(declspec_, T_)
Definition: albaDllMacros.h:84
ALBA_TAG_IDS
Definition: albaTagItem.h:36
@ ALBA_STRING_TAG
Definition: albaTagItem.h:36
@ ALBA_NUMERIC_TAG
Definition: albaTagItem.h:36
@ ALBA_MISSING_TAG
Definition: albaTagItem.h:36
albaStorable is an interface for serializable objects.
Definition: albaStorable.h:41
Abstract class representing the interface for the unit of information stored in the storage.
albaString - performs common string operations on c-strings.
Definition: albaString.h:43
an utility class for storing <key-type-array of values> information.
Definition: albaTagItem.h:47
void GetTypeAsString(albaString &value) const
return the type of this tag item as a string.
albaTagItem(const char *name, const char *value, int t=ALBA_STRING_TAG)
Constructors for with implicit Tag type...
void SetComponents(const std::vector< double > components)
Set array of components at a once, specifying an array of numeric values.
const char * GetComponent(int comp) const
same as GetValue()
void SetComponent(const double value, int component=0)
Set Tag value converting automatically to string and setting the type to NUMERIC.
void GetValueAsSingleString(std::string &str) const
albaTagItem(const char *name, const char **values, int numcomp, int t=ALBA_STRING_TAG)
void SetNumberOfComponents(int n)
Set the NumberOfComponents of the value corresponding to this Tag.
void operator=(const albaTagItem &p)
virtual int InternalRestore(albaStorageElement *node)
This is called by Restore() and must be reimplemented by subclasses The element from which the object...
std::vector< albaString > m_Components
Definition: albaTagItem.h:177
void SetComponents(const std::vector< albaString > components)
Set array of components at a once.
void SetName(const char *name)
Set/Get the name of this Tag.
const char * GetName() const
albaTagItem(const char *name, const double value)
albaString m_Name
Definition: albaTagItem.h:175
albaTagItem(const char *name, const std::vector< albaString > &values, int numcomp, int t=ALBA_STRING_TAG)
bool operator!=(const albaTagItem &p) const
void SetComponents(const char **values, int numcomp)
Set array of components at a once.
void GetTypeAsString(std::string &value) const
void SetValue(const double value, int component=0)
Set Tag value converting automatically to string and setting the type to NUMERIC.
bool operator==(const albaTagItem &p) const
void SetValue(const albaString value, int component=0)
Set the Value of this Tag.
void SetValues(const double *values, int numcomp)
Set array of components at a once, specifying an array of numeric values.
double GetValueAsDouble(int component=0) const
return the value stored in this item converting to a double.
const char * GetValue(int component=0) const
return the value stored in this item.
albaTagItem(const char *name, const double *value, int numcomp)
albaTagItem(const char *name, const std::vector< double > &values, int numcomp)
virtual void Print(std::ostream &os, const int indent=0) const
void RemoveValue(int component)
Remove a value
int GetType() const
return the type of this tag.
Definition: albaTagItem.h:146
void Initialize()
void SetComponents(const double *components, int numcomp)
Set array of components at a once, specifying an array of numeric values.
void SetValues(const std::vector< albaString > values)
same as SetComponents()
void SetValues(const char **values, int numcomp)
same as SetComponents()
virtual int InternalStore(albaStorageElement *parent)
This is called by Store() and must be reimplemented by subclasses.
void DeepCopy(const albaTagItem *item)
copy contents of the given tag item
void GetValueAsSingleString(albaString &str) const
return the array of values as a single string, representing the array of components as a tuple of the...
std::vector< double > GetComponentsAsDoubles() const
return vector of values as doubles
albaTagItem(const albaTagItem &p)
void SetType(int t)
Set the type of this Tag.
Definition: albaTagItem.h:140
double GetComponentAsDouble(int comp) const
void SetComponent(const albaString value, int component=0)
same as SetValue()
const std::vector< albaString > * GetComponents() const
return all the array of values
Definition: albaTagItem.h:122
bool Equals(const albaTagItem *item) const
Compare two Tag items.
int GetNumberOfComponents() const
void SetValues(const std::vector< double > values)
Set array of components at a once, specifying an array of numeric values.
albaUtility - the pourpose of this class is just to groups utilities classes
Definition: albaUtility.h:27