Go to the documentation of this file.
31 #ifndef AIPS_USE_DEPRECATED
32 #error "Map.h is deprecated; use -DBUILD_DEPRECATED=ON to use it"
36 #include <casacore/casa/aips.h>
37 #include <casacore/casa/Exceptions/Error.h>
42 #define AIPS_STUPID_SUN 1
56 template<
class key,
class value>
class Map;
62 template<
class key,
class value>
class MapRep {
118 virtual void remove(
const key &) = 0;
124 virtual void clear() = 0;
155 template<
class key,
class value>
class Map
207 void remove(
const key &k);
240 #if defined(AIPS_STUPID_SUN)
277 template<
class key,
class value>
class MapIterRep {
311 virtual const key &
getKey()
const = 0;
341 void remove(
const key &ky);
391 virtual MapIterRep<key,value> *
Clone() = 0;
463 virtual const key &
getKey()
const;
613 return(this->
Rep->define(ky,val));
618 this->
Rep->remove(ky);
635 return this->
Rep->defaultVal();
662 return(this->
Rep->operator()(ky));
681 return(this->
Rep->isDefined(ky));
746 return(this->
Rep->container());}
780 #ifndef CASACORE_NO_AUTO_TEMPLATES
781 #include <casacore/casa/Containers/Map.tcc>
782 #endif //# CASACORE_NO_AUTO_TEMPLATES
virtual Bool atStart() const
void throw_map_init_error()
virtual Bool atStart() const =0
virtual ~MapRep()
Does nothing.
value DefaultVal
This is the default value which is return when no match is found.
value & define(const key &ky, const value &val)
These functions allow for the definition and removal of key/value relations.
void SetRep(MapIterRep< key, value > *st)
Always DELETES Rep if necessary.
MapIterRep< key, value > * Rep
const value * isDefined(const key &k) const
Returns a non-zero value if a mapping is defined for the key parameter.
void throw_invalid_mapiter_error()
virtual void toStart()
Move the iterator to the start of the Map.
virtual Bool isValid() const =0
Check to see if the iterator is in a valid state.
virtual MapIterRep< key, value > * getRep(Map< key, value > *) const =0
MapIter(Map< key, value > &st)
const value & operator()(const key &ky) const
Allows mapping functions to be performed with the map on which this iterator operates.
virtual MapIter< key, value > & operator=(Map< key, value > &other)
This assignment operator allows the Map which this MapIter tracks to be changed.
virtual value & getVal()=0
Return the value at the current location of the map iterator.
virtual void clear()=0
Clear all of the mappings.
Map< key, value > & container()
Returns the container on which this iterator is operating.
value & operator()(const key &ky)
This is the mapping function which maps keys to values.
virtual MapIterRep< key, value > * Clone()=0
Duplicate a map iterator.
virtual const key & getKey() const =0
Get the key for the current position in the Map.
const Map< key, value > & container() const
void SetRep(MapRep< key, value > *st)
Used the set the representation.
void remove(const key &ky)
virtual Bool atEnd() const =0
Check to see if the iterator position is at the end or beginning of the Map.
ConstMapIter< key, value > & operator=(const Map< key, value > *)
uInt ndefined() const
Returns the number of user defined mappings.
const value & defaultVal() const
void throw_mapiter_init_error()
MapIter(Map< key, value > *other)
This allows a MapIter to be constructed from a Map.
ConstMapIter< key, value > * getIter() const
virtual Bool atEnd() const
Check to see if the iterator position is at the end or beginning of the Map.
value & define(const key &ky, const value &val)
These functions allow for the definition and removal of key/value relations.
virtual void toStart()=0
Move the iterator to the start of the Map.
void clear()
Clear all of the mappings.
value & operator()(const key &ky)
This is the mapping function which maps keys to values.
virtual const value & getVal() const
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Map representation class.
virtual value & define(const key &, const value &)=0
These functions allow for the definition and removal of key/value relations.
const value & defaultVal() const
Returns the default value for the Map on which this iterator is operating if it is a valid iterator,...
virtual void operator++()=0
Advance to the next element of the Map.
value & operator()(const key &ky)
virtual ConstMapIter< key, value > & operator=(const Map< key, value > &other)
Assign one map iterator to a map (with reference semantics).
uInt ndefined() const
Returns the number of user defined mappings.
virtual void operator++()
Advance to the next element of the Map.
MapIterRep(Map< key, value > &st)
This allows a MapIter to be constructed from a Map.
Associative array iterator.
Map< key, value > & container()
Returns the container on which this iterator is operating.
Abstract base class for associative array iterators.
const value * isDefined(const key &ky) const
Allows one to check to see if a given key is defined in the map which this iterator tracks.
const value & operator()(const key &ky) const
Allows mapping functions to be performed with the map on which this iterator operates.
virtual void remove(const key &)=0
MapIter(const MapIter< key, value > &other)
This allows a MapIter to be constructed from another MapIter.
const value & defaultVal() const
This returns the default value for the map that this iterator is tracking.
ConstMapIter(MapIterRep< key, value > *st)
Dummy used to initialization by derived classes.
virtual MapRep< key, value > * Clone() const =0
this file contains all the compiler specific defines
void clear()
Clear all of the mappings.
const value * isDefined(const key &ky) const
Allows one to check to see if a given key is defined in the map which this iterator tracks.
Map(const Map< key, value > &m)
This copy constructor will, for the moment, be the only way to create a map.
virtual const value * isDefined(const key &) const =0
Returns a non-zero value if a mapping is defined for the key parameter.
ConstMapIter< key, value > & operator=(const Map< key, value > &)
Assign one map iterator to a map (with reference semantics).
MapRep(const value &dflt)
This is the only MapRep constructor.
void remove(const key &k)
const value & defaultVal() const
This returns the default value for the map that this iterator is tracking.
value & defaultVal()
Returns the default value for the Map.
void clear()
Clear all of the mappings.
ConstMapIter< key, value > & operator=(const ConstMapIter< key, value > &)
Assign one map iterator to another iterator (with reference semantics).
MapIter(const MapIter< key, value > *other)
const Map< key, value > & container() const
Returns the container on which this iterator is operating.
void remove(const key &ky)
value & define(const key &k, const value &v)
These functions allow for the definition and removal of key/value relations.
virtual Bool isValid() const
Check to see if the iterator is in a valid state.
MapRep< key, value > * Rep
ConstMapIter()
Default constructor creates an invalid Map iterator.
value & defaultVal()
Returns the default value for the Map.
bool Bool
Define the standard types used by Casacore.
value * isDefined(const key &ky)
virtual uInt ndefined() const =0
Returns the number of user defined mappings.
Const associative array iterator.
virtual value & getVal()
Return the value at the current location of the map iterator.
void throw_map_constop_error()
Map< key, value > & operator=(const Map< key, value > &)
Abstract base class for associative arrays.
const value & operator()(const key &ky) const
Allows mapping functions to be performed with the map on which this iterator operates.
uInt ndefined() const
Returns the number of user defined mappings.
MapIterRep< key, value > * getRep() const
Returns the iterator rep appropriate for this particular Map.
ConstMapIter< key, value > & operator=(const ConstMapIter< key, value > *)
const value * isDefined(const key &ky) const
Allows one to check to see if a given key is defined in the map which this iterator tracks.
Map< key, value > * Container
virtual const key & getKey() const
Get the key or value for the current position in the Map.
MapIter()
Default constructor creates an invalid Map iterator.