TBTK
AbstractProperty.h
1 /* Copyright 2017 Kristofer Bj√∂rnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
23 #ifndef COM_DAFER45_TBTK_ABSTRACT_PROPERTY
24 #define COM_DAFER45_TBTK_ABSTRACT_PROPERTY
25 
27 #include "TBTK/SpinMatrix.h"
28 #include "TBTK/TBTKMacros.h"
29 
30 #include "TBTK/json.hpp"
31 
32 namespace TBTK{
33 namespace Property{
34 
36 template<
37  typename DataType,
38  bool isFundamental = std::is_fundamental<DataType>::value,
39  bool isSerializable = std::is_base_of<Serializable, DataType>::value
40 >
42 public:
44  unsigned int getBlockSize() const;
45 
47  void setSize(unsigned int size);
48 
50  unsigned int getSize() const;
51 
53  const DataType* getData() const;
54 
56  DataType* getDataRW();
57 
59  unsigned int getSizeInBytes() const;
60 
62  char* getRawData();
63 
65  unsigned int getDimensions() const;
66 
68 // const int* getRanges() const;
69  std::vector<int> getRanges() const;
70 
72  int getOffset(const Index &index) const;
73 
75  const IndexDescriptor& getIndexDescriptor() const;
76 
78  bool contains(const Index &index) const;
79 
81  virtual const DataType& operator()(const Index &index, unsigned int offset = 0) const;
82 
84  virtual DataType& operator()(const Index &index, unsigned int offset = 0);
85 
87  virtual const DataType& operator()(unsigned int offset) const;
88 
90  virtual DataType& operator()(unsigned int offset);
91 
96  void setAllowIndexOutOfBoundsAccess(bool allowIndexOutOfBoundsAccess);
97 
101  void setDefaultValue(const DataType &defaultValue);
102 
104  virtual std::string serialize(Mode mode) const;
105 protected:
108 
111  unsigned int blockSize
112  );
113 
116  unsigned int blockSize,
117  const DataType *data
118  );
119 
122  unsigned int dimensions,
123  const int *ranges,
124  unsigned int blockSize
125  );
126 
129  unsigned int dimensions,
130  const int *ranges,
131  unsigned int blockSize,
132  const DataType *data
133  );
134 
137  const IndexTree &indexTree,
138  unsigned int blockSize
139  );
140 
143  const IndexTree &indexTree,
144  unsigned int blockSize,
145  const DataType *data
146  );
147 
149  AbstractProperty(const AbstractProperty &abstractProperty);
150 
152  AbstractProperty(AbstractProperty &&abstractProperty);
153 
157  const std::string &serialization,
158  Mode mode
159  );
160 
162  virtual ~AbstractProperty();
163 
165  AbstractProperty& operator=(const AbstractProperty &abstractProperty);
166 
168  AbstractProperty& operator=(AbstractProperty &&abstractProperty);
169 private:
171  IndexDescriptor indexDescriptor;
172 
176  unsigned int blockSize;
177 
179  unsigned int size;
180 
182  DataType *data;
183 
185  bool allowIndexOutOfBoundsAccess;
186 
188  DataType defaultValue;
189 };
190 
191 template<typename DataType, bool isFundamental, bool isSerializable>
192 inline unsigned int AbstractProperty<
193  DataType,
194  isFundamental,
195  isSerializable
196 >::getBlockSize() const{
197  return blockSize;
198 }
199 
200 template<typename DataType, bool isFundamental, bool isSerializable>
201 inline void AbstractProperty<
202  DataType,
203  isFundamental,
204  isSerializable
205 >::setSize(unsigned int size){
206  this->size = size;
207  if(data != nullptr)
208  delete [] data;
209  data = new DataType[size];
210 }
211 
212 template<typename DataType, bool isFundamental, bool isSerializable>
213 inline unsigned int AbstractProperty<
214  DataType,
215  isFundamental,
216  isSerializable
217 >::getSize() const{
218  return size;
219 }
220 
221 template<typename DataType, bool isFundamental, bool isSerializable>
222 inline const DataType* AbstractProperty<
223  DataType,
224  isFundamental,
225  isSerializable
226 >::getData() const{
227  return data;
228 }
229 
230 template<typename DataType, bool isFundamental, bool isSerializable>
231 inline DataType* AbstractProperty<
232  DataType,
233  isFundamental,
234  isSerializable
236  return data;
237 }
238 
239 template<typename DataType, bool isFundamental, bool isSerializable>
240 inline unsigned int AbstractProperty<
241  DataType,
242  isFundamental,
243  isSerializable
245  return size*sizeof(DataType);
246 }
247 
248 template<typename DataType, bool isFundamental, bool isSerializable>
249 inline char* AbstractProperty<
250  DataType,
251  isFundamental,
252  isSerializable
254  return (char*)data;
255 }
256 
257 template<typename DataType, bool isFundamental, bool isSerializable>
258 inline unsigned int AbstractProperty<
259  DataType,
260  isFundamental,
261  isSerializable
263  return indexDescriptor.getDimensions();
264 }
265 
266 template<typename DataType, bool isFundamental, bool isSerializable>
267 //inline const int* AbstractProperty<
268 inline std::vector<int> AbstractProperty<
269  DataType,
270  isFundamental,
271  isSerializable
272 >::getRanges() const{
273  return indexDescriptor.getRanges();
274 }
275 
276 template<typename DataType, bool isFundamental, bool isSerializable>
277 inline int AbstractProperty<
278  DataType,
279  isFundamental,
280  isSerializable
282  const Index &index
283 ) const{
284  return blockSize*indexDescriptor.getLinearIndex(
285  index,
286  allowIndexOutOfBoundsAccess
287  );
288 }
289 
290 template<typename DataType, bool isFundamental, bool isSerializable>
291 inline const IndexDescriptor& AbstractProperty<
292  DataType,
293  isFundamental,
294  isSerializable
296 ) const{
297  return indexDescriptor;
298 }
299 
300 template<typename DataType, bool isFundamental, bool isSerializable>
301 inline bool AbstractProperty<
302  DataType,
303  isFundamental,
304  isSerializable
306  const Index &index
307 ) const{
308  return indexDescriptor.contains(index);
309 }
310 
311 template<typename DataType, bool isFundamental, bool isSerializable>
312 inline const DataType& AbstractProperty<
313  DataType,
314  isFundamental,
315  isSerializable
316 >::operator()(
317  const Index &index,
318  unsigned int offset
319 ) const{
320 // return data[getOffset(index) + offset];
321  int indexOffset = getOffset(index);
322  if(indexOffset < 0)
323  return defaultValue;
324  else
325  return data[indexOffset + offset];
326 }
327 
328 template<typename DataType, bool isFundamental, bool isSerializable>
329 inline DataType& AbstractProperty<
330  DataType,
331  isFundamental,
332  isSerializable
333 >::operator()(
334  const Index &index,
335  unsigned int offset
336 ){
337 // return data[getOffset(index) + offset];
338  int indexOffset = getOffset(index);
339  if(indexOffset < 0){
340  static DataType defaultValueNonConst = defaultValue;
341  return defaultValueNonConst;
342  }
343  else{
344  return data[indexOffset + offset];
345  }
346 }
347 
348 template<typename DataType, bool isFundamental, bool isSerializable>
349 inline const DataType& AbstractProperty<
350  DataType,
351  isFundamental,
352  isSerializable
353 >::operator()(unsigned int offset) const{
354  return data[offset];
355 }
356 
357 template<typename DataType, bool isFundamental, bool isSerializable>
358 inline DataType& AbstractProperty<
359  DataType,
360  isFundamental,
361  isSerializable
362 >::operator()(unsigned int offset){
363  return data[offset];
364 }
365 
366 template<typename DataType, bool isFundamental, bool isSerializable>
367 inline void AbstractProperty<
368  DataType,
369  isFundamental,
370  isSerializable
371 >::setAllowIndexOutOfBoundsAccess(bool allowIndexOutOfBoundsAccess){
372  this->allowIndexOutOfBoundsAccess = allowIndexOutOfBoundsAccess;
373 }
374 
375 template<typename DataType, bool isFundamental, bool isSerializable>
376 inline void AbstractProperty<
377  DataType,
378  isFundamental,
379  isSerializable
380 >::setDefaultValue(const DataType &defaultValue){
381  this->defaultValue = defaultValue;
382 }
383 
384 template<>
385 inline std::string AbstractProperty<
386  bool,
387  true,
388  false
389 >::serialize(Mode mode) const{
390  switch(mode){
391  case Mode::JSON:
392  {
393  nlohmann::json j;
394  j["id"] = "AbstractProperty";
395  j["indexDescriptor"] = nlohmann::json::parse(
396  indexDescriptor.serialize(mode)
397  );
398  j["blockSize"] = blockSize;
399  j["size"] = size;
400  for(unsigned int n = 0; n < size; n++)
401  j["data"].push_back(data[n]);
402 
403  return j.dump();
404  }
405  default:
406  TBTKExit(
407  "AbstractProperty<DataType>::serialize()",
408  "Only Serializable::Mode::JSON is supported yet.",
409  ""
410  );
411  }
412 }
413 
414 template<>
415 inline std::string AbstractProperty<
416  char,
417  true,
418  false
419 >::serialize(Mode mode) const{
420  switch(mode){
421  case Mode::JSON:
422  {
423  nlohmann::json j;
424  j["id"] = "AbstractProperty";
425  j["indexDescriptor"] = nlohmann::json::parse(
426  indexDescriptor.serialize(mode)
427  );
428  j["blockSize"] = blockSize;
429  j["size"] = size;
430  for(unsigned int n = 0; n < size; n++)
431  j["data"].push_back(data[n]);
432 
433  return j.dump();
434  }
435  default:
436  TBTKExit(
437  "AbstractProperty<DataType>::serialize()",
438  "Only Serializable::Mode::JSON is supported yet.",
439  ""
440  );
441  }
442 }
443 
444 template<>
445 inline std::string AbstractProperty<
446  int,
447  true,
448  false
449 >::serialize(Mode mode) const{
450  switch(mode){
451  case Mode::JSON:
452  {
453  nlohmann::json j;
454  j["id"] = "AbstractProperty";
455  j["indexDescriptor"] = nlohmann::json::parse(
456  indexDescriptor.serialize(mode)
457  );
458  j["blockSize"] = blockSize;
459  j["size"] = size;
460  for(unsigned int n = 0; n < size; n++)
461  j["data"].push_back(data[n]);
462 
463  return j.dump();
464  }
465  default:
466  TBTKExit(
467  "AbstractProperty<DataType>::serialize()",
468  "Only Serializable::Mode::JSON is supported yet.",
469  ""
470  );
471  }
472 }
473 
474 template<>
475 inline std::string AbstractProperty<
476  float,
477  true,
478  false
479 >::serialize(Mode mode) const{
480  switch(mode){
481  case Mode::JSON:
482  {
483  nlohmann::json j;
484  j["id"] = "AbstractProperty";
485  j["indexDescriptor"] = nlohmann::json::parse(
486  indexDescriptor.serialize(mode)
487  );
488  j["blockSize"] = blockSize;
489  j["size"] = size;
490  for(unsigned int n = 0; n < size; n++)
491  j["data"].push_back(data[n]);
492 
493  return j.dump();
494  }
495  default:
496  TBTKExit(
497  "AbstractProperty<DataType>::serialize()",
498  "Only Serializable::Mode::JSON is supported yet.",
499  ""
500  );
501  }
502 }
503 
504 template<>
505 inline std::string AbstractProperty<
506  double,
507  true,
508  false
509 >::serialize(Mode mode) const{
510  switch(mode){
511  case Mode::JSON:
512  {
513  nlohmann::json j;
514  j["id"] = "AbstractProperty";
515  j["indexDescriptor"] = nlohmann::json::parse(
516  indexDescriptor.serialize(mode)
517  );
518  j["blockSize"] = blockSize;
519  j["size"] = size;
520  for(unsigned int n = 0; n < size; n++)
521  j["data"].push_back(data[n]);
522 
523  return j.dump();
524  }
525  default:
526  TBTKExit(
527  "AbstractProperty<DataType>::serialize()",
528  "Only Serializable::Mode::JSON is supported yet.",
529  ""
530  );
531  }
532 }
533 
534 template<>
535 inline std::string AbstractProperty<std::complex<double>, false, false>::serialize(Mode mode) const{
536  switch(mode){
537  case Mode::JSON:
538  {
539  nlohmann::json j;
540  j["id"] = "AbstractProperty";
541  j["indexDescriptor"] = nlohmann::json::parse(
542  indexDescriptor.serialize(mode)
543  );
544  j["blockSize"] = blockSize;
545  j["size"] = size;
546  for(unsigned int n = 0; n < size; n++){
547 // std::stringstream ss;
548 // ss << "(" << real(data[n]) << "," << imag(data[n]) << ")";
549  std::string s = Serializable::serialize(data[n], mode);
550  j["data"].push_back(s);
551  }
552 
553  return j.dump();
554  }
555  default:
556  TBTKExit(
557  "AbstractProperty<DataType>::serialize()",
558  "Only Serializable::Mode::JSON is supported yet.",
559  ""
560  );
561  }
562 }
563 
564 template<>
566  TBTKNotYetImplemented("AbstractProperty<SpinMatrix, false, false>::serialize()");
567 }
568 
569 template<typename DataType, bool isFundamental, bool isSerializable>
571  DataType,
572  isFundamental,
573  isSerializable
575  indexDescriptor(IndexDescriptor::Format::None)
576 {
577  this->blockSize = 0;
578 
579  size = blockSize;
580  data = nullptr;
581 }
582 
583 template<typename DataType, bool isFundamental, bool isSerializable>
585  DataType,
586  isFundamental,
587  isSerializable
589  unsigned int blockSize
590 ) :
591  indexDescriptor(IndexDescriptor::Format::None)
592 {
593  this->blockSize = blockSize;
594 
595  size = blockSize;
596  data = new DataType[size];
597  for(unsigned int n = 0; n < size; n++)
598  data[n] = 0.;
599 }
600 
601 template<typename DataType, bool isFundamental, bool isSerializable>
603  DataType,
604  isFundamental,
605  isSerializable
607  unsigned int blockSize,
608  const DataType *data
609 ) :
610  indexDescriptor(IndexDescriptor::Format::None)
611 {
612  this->blockSize = blockSize;
613 
614  size = blockSize;
615  this->data = new DataType[size];
616  for(unsigned int n = 0; n < size; n++)
617  this->data[n] = data[n];
618 }
619 
620 template<typename DataType, bool isFundamental, bool isSerializable>
622  DataType,
623  isFundamental,
624  isSerializable
626  unsigned int dimensions,
627  const int *ranges,
628  unsigned int blockSize
629 ) :
630  indexDescriptor(IndexDescriptor::Format::Ranges)
631 {
632  this->blockSize = blockSize;
633 
634 /* indexDescriptor.setDimensions(dimensions);
635  int *thisRanges = indexDescriptor.getRanges();
636  for(unsigned int n = 0; n < dimensions; n++)
637  thisRanges[n] = ranges[n];*/
638  indexDescriptor.setRanges(ranges, dimensions);
639 
640  size = blockSize*indexDescriptor.getSize();
641  data = new DataType[size];
642  for(unsigned int n = 0; n < size; n++)
643  data[n] = 0.;
644 }
645 
646 template<typename DataType, bool isFundamental, bool isSerializable>
648  DataType,
649  isFundamental,
650  isSerializable
652  unsigned int dimensions,
653  const int *ranges,
654  unsigned int blockSize,
655  const DataType *data
656 ) :
657  indexDescriptor(IndexDescriptor::Format::Ranges)
658 {
659  this->blockSize = blockSize;
660 
661 /* indexDescriptor.setDimensions(dimensions);
662  int *thisRanges = indexDescriptor.getRanges();
663  for(unsigned int n = 0; n < dimensions; n++)
664  thisRanges[n] = ranges[n];*/
665  indexDescriptor.setRanges(ranges, dimensions);
666 
667  size = blockSize*indexDescriptor.getSize();
668  this->data = new DataType[size];
669  for(unsigned int n = 0; n < size; n++)
670  this->data[n] = data[n];
671 }
672 
673 template<typename DataType, bool isFundamental, bool isSerializable>
675  DataType,
676  isFundamental,
677  isSerializable
679  const IndexTree &indexTree,
680  unsigned int blockSize
681 ) :
682  indexDescriptor(IndexDescriptor::Format::Custom)
683 {
684  this->blockSize = blockSize;
685 
686  indexDescriptor.setIndexTree(indexTree);
687 
688  size = blockSize*indexDescriptor.getSize();
689  data = new DataType[size];
690  for(unsigned int n = 0; n < size; n++)
691  data[n] = 0.;
692 }
693 
694 template<typename DataType, bool isFundamental, bool isSerializable>
696  DataType,
697  isFundamental,
698  isSerializable
700  const IndexTree &indexTree,
701  unsigned int blockSize,
702  const DataType *data
703 ) :
704  indexDescriptor(IndexDescriptor::Format::Custom)
705 {
706  this->blockSize = blockSize;
707 
708  indexDescriptor.setIndexTree(indexTree);
709 
710  size = blockSize*indexDescriptor.getSize();
711  this->data = new DataType[size];
712  for(unsigned int n = 0; n < size; n++)
713  this->data[n] = data[n];
714 }
715 
716 template<typename DataType, bool isFundamental, bool isSerializable>
718  DataType,
719  isFundamental,
720  isSerializable
722  const AbstractProperty &abstractProperty
723 ) :
724  indexDescriptor(abstractProperty.indexDescriptor)
725 {
726  blockSize = abstractProperty.blockSize;
727 
728  size = abstractProperty.size;
729  if(abstractProperty.data == nullptr){
730  data = nullptr;
731  }
732  else{
733  data = new DataType[size];
734  for(unsigned int n = 0; n < size; n++)
735  data[n] = abstractProperty.data[n];
736  }
737 }
738 
739 template<typename DataType, bool isFundamental, bool isSerializable>
741  DataType,
742  isFundamental,
743  isSerializable
745  AbstractProperty &&abstractProperty
746 ) :
747  indexDescriptor(std::move(abstractProperty.indexDescriptor))
748 {
749  blockSize = abstractProperty.blockSize;
750 
751  size = abstractProperty.size;
752  if(abstractProperty.data == nullptr){
753  data = nullptr;
754  }
755  else{
756  data = abstractProperty.data;
757  abstractProperty.data = nullptr;
758  }
759 }
760 
761 template<>
763  const std::string &serialization,
764  Mode mode
765 ) :
766  indexDescriptor(
767  Serializable::extract(serialization, mode, "indexDescriptor"),
768  mode
769  )
770 {
771  TBTKAssert(
772  validate(serialization, "AbstractProperty", mode),
773  "AbstractProperty::AbstractProperty()",
774  "Unable to parse string as AbstractProperty '" << serialization
775  << "'.",
776  ""
777  );
778 
779  switch(mode){
780  case Mode::JSON:
781  try{
782  nlohmann::json j = nlohmann::json::parse(serialization);
783  blockSize = j.at("blockSize").get<unsigned int>();
784  size = j.at("size").get<unsigned int>();
785  data = new double[size];
786  nlohmann::json d = j.at("data");
787  unsigned int counter = 0;
788  for(
789  nlohmann::json::iterator it = d.begin();
790  it < d.end();
791  ++it
792  ){
793  data[counter] = *it;
794  counter++;
795  }
796  }
797  catch(nlohmann::json::exception e){
798  TBTKExit(
799  "AbstractProperty::AbstractProperty()",
800  "Unable to parse string as AbstractProperty '"
801  << serialization << "'.",
802  ""
803  );
804  }
805 
806  break;
807  default:
808  TBTKExit(
809  "AbstractProperty::AbstractProperty()",
810  "Only Serializable::Mode::JSON is supported yet.",
811  ""
812  );
813  }
814 }
815 
816 template<>
817 inline AbstractProperty<std::complex<double>, false, false>::AbstractProperty(
818  const std::string &serialization,
819  Mode mode
820 ) :
821  indexDescriptor(
822  Serializable::extract(serialization, mode, "indexDescriptor"),
823  mode
824  )
825 {
826  TBTKAssert(
827  validate(serialization, "AbstractProperty", mode),
828  "AbstractProperty::AbstractProperty()",
829  "Unable to parse string as AbstractProperty '" << serialization
830  << "'.",
831  ""
832  );
833 
834  switch(mode){
835  case Mode::JSON:
836  try{
837  nlohmann::json j = nlohmann::json::parse(serialization);
838  blockSize = j.at("blockSize").get<unsigned int>();
839  size = j.at("size").get<unsigned int>();
840  data = new std::complex<double>[size];
841  nlohmann::json d = j.at("data");
842  unsigned int counter = 0;
843  for(
844  nlohmann::json::iterator it = d.begin();
845  it < d.end();
846  ++it
847  ){
848  std::complex<double> c;
849  Serializable::deserialize(it->get<std::string>(), &c, mode);
850  data[counter] = c;
851  counter++;
852  }
853  }
854  catch(nlohmann::json::exception e){
855  TBTKExit(
856  "AbstractProperty::AbstractProperty()",
857  "Unable to parse string as AbstractProperty '"
858  << serialization << "'.",
859  ""
860  );
861  }
862 
863  break;
864  default:
865  TBTKExit(
866  "AbstractProperty::AbstractProperty()",
867  "Only Serializable::Mode::JSON is supported yet.",
868  ""
869  );
870  }
871 }
872 
873 template<>
875  const std::string &serialization,
876  Mode mode
877 ) :
878  indexDescriptor(
879  Serializable::extract(serialization, mode, "indexDescriptor"),
880  mode
881  )
882 {
883  TBTKNotYetImplemented("AbstractProperty<SpinMatrix, false, false>::AbstractProperty()");
884 }
885 
886 template<typename DataType, bool isFundamental, bool isSerializable>
887 inline AbstractProperty<
888  DataType,
889  isFundamental,
890  isSerializable
892  if(data != nullptr)
893  delete [] data;
894 }
895 
896 template<typename DataType, bool isFundamental, bool isSerializable>
898  DataType,
899  isFundamental,
900  isSerializable
902  DataType,
903  isFundamental,
904  isSerializable
905 >::operator=(
906  const AbstractProperty &rhs
907 ){
908  if(this != &rhs){
909  indexDescriptor = rhs.indexDescriptor;
910 
911  blockSize = rhs.blockSize;
912 
913  size = rhs.size;
914  if(data != nullptr)
915  delete [] data;
916 
917  if(rhs.data == nullptr){
918  data = nullptr;
919  }
920  else{
921  data = new DataType[size];
922  for(unsigned int n = 0; n < size; n++)
923  data[n] = rhs.data[n];
924  }
925  }
926 
927  return *this;
928 }
929 
930 template<typename DataType, bool isFundamental, bool isSerializable>
932  DataType,
933  isFundamental,
934  isSerializable
936  DataType,
937  isFundamental,
938  isSerializable
939 >::operator=(
940  AbstractProperty &&rhs
941 ){
942  if(this != &rhs){
943  indexDescriptor = std::move(rhs.indexDescriptor);
944 
945  blockSize = rhs.blockSize;
946 
947  size = rhs.size;
948  if(data != nullptr)
949  delete [] data;
950 
951  if(rhs.data == nullptr){
952  data = nullptr;
953  }
954  else{
955  data = rhs.data;
956  rhs.data = nullptr;
957  }
958  }
959 
960  return *this;
961 }
962 
963 }; //End namespace Property
964 }; //End namespace TBTK
965 
966 #endif
static std::string extract(const std::string &serialization, Mode mode, std::string component)
unsigned int getSize() const
const DataType * getData() const
Definition: AbstractProperty.h:226
unsigned int getSizeInBytes() const
Definition: AbstractProperty.h:244
void setDefaultValue(const DataType &defaultValue)
Definition: AbstractProperty.h:380
void setAllowIndexOutOfBoundsAccess(bool allowIndexOutOfBoundsAccess)
Definition: AbstractProperty.h:371
virtual ~AbstractProperty()
Definition: AbstractProperty.h:891
Describes the index structure of data stored for several indices.
Definition: IndexDescriptor.h:33
Precompiler macros.
Definition: Serializable.h:40
bool contains(const Index &index) const
Definition: AbstractProperty.h:305
virtual std::string serialize(Mode mode) const
const IndexDescriptor & getIndexDescriptor() const
Definition: AbstractProperty.h:295
std::vector< int > getRanges() const
Definition: AbstractProperty.h:272
void setSize(unsigned int size)
Definition: AbstractProperty.h:205
std::vector< int > getRanges() const
Definition: IndexDescriptor.h:176
void setRanges(const int *ranges, unsigned int dimensions)
Definition: IndexDescriptor.h:160
virtual const DataType & operator()(const Index &index, unsigned int offset=0) const
Definition: AbstractProperty.h:316
virtual std::string serialize(Mode mode) const
unsigned int getBlockSize() const
Definition: AbstractProperty.h:196
Describes the index structure of data stored for several indices.
Abstract Property class.
Definition: AbstractProperty.h:41
unsigned int getSize() const
Definition: AbstractProperty.h:217
Data structure for mapping physical indices to a linear index.
Definition: IndexTree.h:34
Flexible physical index.
Definition: Index.h:70
char * getRawData()
Definition: AbstractProperty.h:253
Definition: ModelFactory.h:35
DataType * getDataRW()
Definition: AbstractProperty.h:235
unsigned int getDimensions() const
Definition: IndexDescriptor.h:150
AbstractProperty()
Definition: AbstractProperty.h:574
AbstractProperty & operator=(const AbstractProperty &abstractProperty)
Definition: AbstractProperty.h:905
static void deserialize(const std::string &serialization, bool *b, Mode mode)
Definition: Serializable.h:171
int getLinearIndex(const Index &index, bool returnNegativeForMissingIndex=false) const
Definition: IndexDescriptor.h:213
Mode
Definition: Serializable.h:44
static bool validate(const std::string &serialization, const std::string &id, Mode mode)
virtual std::string serialize(Mode mode) const =0
unsigned int getDimensions() const
Definition: AbstractProperty.h:262
void setIndexTree(const IndexTree &indexTree)
bool contains(const Index &index) const
Definition: IndexDescriptor.h:231
int getOffset(const Index &index) const
Definition: AbstractProperty.h:281