CiftiLib
A C++ library for CIFTI-2 and CIFTI-1 files
CiftiLabelsMap.h
1 #ifndef __CIFTI_LABELS_MAP_H__
2 #define __CIFTI_LABELS_MAP_H__
3 
4 /*LICENSE_START*/
5 /*
6  * Copyright (c) 2014, Washington University School of Medicine
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include "CiftiMappingType.h"
32 
33 #include "Common/AString.h"
34 #include "MetaData.h"
35 #include "LabelTable.h"
36 
37 #include <map>
38 #include <vector>
39 
40 namespace cifti
41 {
43  {
44  public:
45  const MetaData& getMapMetadata(const int64_t& index) const;
46  const LabelTable& getMapLabelTable(const int64_t& index) const;
47  const AString& getMapName(const int64_t& index) const;
48 
49  void setMapMetadata(const int64_t& index, const MetaData& md);
50  void setMapLabelTable(const int64_t& index, const LabelTable& lt);
51  void setMapName(const int64_t& index, const AString& mapName);
52  void setLength(const int64_t& length);
53  void clear();
54 
55  CiftiMappingType* clone() const { return new CiftiLabelsMap(*this); }
56  MappingType getType() const { return LABELS; }
57  int64_t getLength() const { return m_maps.size(); }
58  bool operator==(const CiftiMappingType& rhs) const;
59  bool approximateMatch(const CiftiMappingType& rhs, AString* explanation = NULL) const;
60  void readXML1(XmlReader& xml);
61  void readXML2(XmlReader& xml);
62  void writeXML1(XmlWriter& xml) const;
63  void writeXML2(XmlWriter& xml) const;
64  private:
65  struct LabelMap
66  {
67  AString m_name;
68  MetaData m_metaData;
69  LabelTable m_labelTable;
70  bool operator==(const LabelMap& rhs) const;
71  void readXML1(XmlReader& xml);
72  void readXML2(XmlReader& xml);
73  };
74  std::vector<LabelMap> m_maps;
75  };
76 }
77 
78 #endif //__CIFTI_LABELS_MAP_H__
Definition: CiftiLabelsMap.h:43
Definition: CiftiMappingType.h:39
Definition: LabelTable.h:44
Definition: MetaData.h:44
namespace for all CiftiLib functionality
Definition: CiftiBrainModelsMap.h:42