RMF
provenance.h
Go to the documentation of this file.
1 /**
2  * \file RMF/decorator/provenance.h
3  * \brief Helper functions for manipulating RMF files.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef RMF_PROVENANCE_DECORATORS_H
10 #define RMF_PROVENANCE_DECORATORS_H
11 
12 #include <RMF/config.h>
14 #include <RMF/NodeHandle.h>
15 #include <RMF/FileHandle.h>
16 #include <RMF/Decorator.h>
17 #include <RMF/constants.h>
18 #include <RMF/Vector.h>
19 #include <RMF/internal/paths.h>
20 #include <array>
21 #include <boost/lexical_cast.hpp>
22 
23 RMF_ENABLE_WARNINGS
24 namespace RMF {
25 namespace decorator {
26 
27 
28  /** See also StructureProvenance and StructureProvenanceFactory.
29  */
31  friend class StructureProvenanceFactory;
32  protected:
33  StringKey structure_filename_;
34 StringKey structure_chain_;
35 IntKey structure_residue_offset_;
37  StringKey structure_filename,
38 StringKey structure_chain,
39 IntKey structure_residue_offset):
40  Decorator(nh),
41 structure_filename_(structure_filename),
42 structure_chain_(structure_chain),
43 structure_residue_offset_(structure_residue_offset) {
44  }
45  public:
46 
47  String get_filename() const {
48  try {
49  String relpath = get_node().get_value(structure_filename_);
50  String filename = get_node().get_file().get_path();
51  return internal::get_absolute_path(filename, relpath);
52  } RMF_DECORATOR_CATCH( );
53  }
54 
55 
56  String get_chain() const {
57  try {
58  return get_node().get_value(structure_chain_);
59  } RMF_DECORATOR_CATCH( );
60  }
61  String get_frame_chain() const {
62  try {
63  return get_node().get_frame_value(structure_chain_);
64  } RMF_DECORATOR_CATCH( );
65  }
66  String get_static_chain() const {
67  try {
68  return get_node().get_static_value(structure_chain_);
69  } RMF_DECORATOR_CATCH( );
70  }
71 
72 
73  Int get_residue_offset() const {
74  try {
75  if (!get_node().get_has_value(structure_residue_offset_)) return 0;
76 return get_node().get_value(structure_residue_offset_);
77  } RMF_DECORATOR_CATCH( );
78  }
79  Int get_frame_residue_offset() const {
80  try {
81  if (!get_node().get_has_value(structure_residue_offset_)) return 0;
82 return get_node().get_frame_value(structure_residue_offset_);
83  } RMF_DECORATOR_CATCH( );
84  }
85  Int get_static_residue_offset() const {
86  try {
87  if (!get_node().get_has_value(structure_residue_offset_)) return 0;
88 return get_node().get_static_value(structure_residue_offset_);
89  } RMF_DECORATOR_CATCH( );
90  }
91 
92  static std::string get_decorator_type_name() {
93  return "StructureProvenanceConst";
94  }
95  RMF_SHOWABLE(StructureProvenanceConst, "StructureProvenance: " << get_node());
96  };
97  /** See also StructureProvenanceFactory.
98  */
100  friend class StructureProvenanceFactory;
102  StringKey structure_filename,
103 StringKey structure_chain,
104 IntKey structure_residue_offset):
105  StructureProvenanceConst(nh, structure_filename,
106 structure_chain,
107 structure_residue_offset) {
108  }
109  public:
110 
111  void set_filename(String path) {
112  try {
113  String filename = get_node().get_file().get_path();
114  String relpath = internal::get_relative_path(filename, path);
115  get_node().set_value(structure_filename_, relpath);
116  } RMF_DECORATOR_CATCH( );
117  }
118 
119 
120  void set_chain(String v) {
121  try {
122  get_node().set_value(structure_chain_, v);
123  } RMF_DECORATOR_CATCH( );
124  }
125  void set_frame_chain(String v) {
126  try {
127  get_node().set_frame_value(structure_chain_, v);
128  } RMF_DECORATOR_CATCH( );
129  }
130  void set_static_chain(String v) {
131  try {
132  get_node().set_static_value(structure_chain_, v);
133  } RMF_DECORATOR_CATCH( );
134  }
135 
136 
137  void set_residue_offset(Int v) {
138  try {
139  get_node().set_value(structure_residue_offset_, v);
140  } RMF_DECORATOR_CATCH( );
141  }
142  void set_frame_residue_offset(Int v) {
143  try {
144  get_node().set_frame_value(structure_residue_offset_, v);
145  } RMF_DECORATOR_CATCH( );
146  }
147  void set_static_residue_offset(Int v) {
148  try {
149  get_node().set_static_value(structure_residue_offset_, v);
150  } RMF_DECORATOR_CATCH( );
151  }
152 
153  static std::string get_decorator_type_name() {
154  return "StructureProvenance";
155  }
156  };
157 
158 
159  /** Create decorators of type StructureProvenance.
160  */
162  Category cat_;
163 StringKey structure_filename_;
164 StringKey structure_chain_;
165 IntKey structure_residue_offset_;
166 
167 
168 
169  public:
171  cat_(fh.get_category("provenance")),
172  structure_filename_(fh.get_key<StringTag>(cat_, "structure filename")), structure_chain_(fh.get_key<StringTag>(cat_, "structure chain")), structure_residue_offset_(fh.get_key<IntTag>(cat_, "structure residue offset")) {
173  }
175  cat_(fh.get_category("provenance")),
176  structure_filename_(fh.get_key<StringTag>(cat_, "structure filename")), structure_chain_(fh.get_key<StringTag>(cat_, "structure chain")), structure_residue_offset_(fh.get_key<IntTag>(cat_, "structure residue offset")) {
177  }
178  /** Get a StructureProvenanceConst for nh.*/
180  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
181  + boost::lexical_cast<std::string>(nh.get_type())
182  + "\" in decorator type StructureProvenance");
183  return StructureProvenanceConst(nh, structure_filename_,
184 structure_chain_,
185 structure_residue_offset_);
186  }
187  /** Get a StructureProvenance for nh.*/
189  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
190  + boost::lexical_cast<std::string>(nh.get_type())
191  + "\" in decorator type StructureProvenance");
192  return StructureProvenance(nh, structure_filename_,
193 structure_chain_,
194 structure_residue_offset_);
195  }
196  /** Check whether nh has all the attributes required to be a
197  StructureProvenanceConst.*/
198  bool get_is(NodeConstHandle nh) const {
199  return (nh.get_type() == RMF::PROVENANCE)
200  && !nh.get_value(structure_filename_).get_is_null();
201  }
202  bool get_is_static(NodeConstHandle nh) const {
203  return (nh.get_type() == RMF::PROVENANCE)
204  && !nh.get_static_value(structure_filename_).get_is_null()
205  && !nh.get_static_value(structure_chain_).get_is_null();
206  }
207  RMF_SHOWABLE(StructureProvenanceFactory, "StructureProvenanceFactory");
208  };
209  #ifndef RMF_DOXYGEN
210 struct StructureProvenanceConstFactory: public StructureProvenanceFactory {
211  StructureProvenanceConstFactory(FileConstHandle fh):
212  StructureProvenanceFactory(fh) {
213  }
214  StructureProvenanceConstFactory(FileHandle fh):
215  StructureProvenanceFactory(fh) {
216  }
217 
218 };
219  #endif
220 
221 
222 
223 
224  /** See also SampleProvenance and SampleProvenanceFactory.
225  */
227  friend class SampleProvenanceFactory;
228  protected:
229  StringKey sampling_method_;
230 IntKey sampling_frames_;
231 IntKey sampling_iterations_;
232 IntKey sampling_replicas_;
234  StringKey sampling_method,
235 IntKey sampling_frames,
236 IntKey sampling_iterations,
237 IntKey sampling_replicas):
238  Decorator(nh),
239 sampling_method_(sampling_method),
240 sampling_frames_(sampling_frames),
241 sampling_iterations_(sampling_iterations),
242 sampling_replicas_(sampling_replicas) {
243  }
244  public:
245 
246  String get_method() const {
247  try {
248  return get_node().get_value(sampling_method_);
249  } RMF_DECORATOR_CATCH( );
250  }
251  String get_frame_method() const {
252  try {
253  return get_node().get_frame_value(sampling_method_);
254  } RMF_DECORATOR_CATCH( );
255  }
256  String get_static_method() const {
257  try {
258  return get_node().get_static_value(sampling_method_);
259  } RMF_DECORATOR_CATCH( );
260  }
261 
262 
263  Int get_frames() const {
264  try {
265  return get_node().get_value(sampling_frames_);
266  } RMF_DECORATOR_CATCH( );
267  }
268  Int get_frame_frames() const {
269  try {
270  return get_node().get_frame_value(sampling_frames_);
271  } RMF_DECORATOR_CATCH( );
272  }
273  Int get_static_frames() const {
274  try {
275  return get_node().get_static_value(sampling_frames_);
276  } RMF_DECORATOR_CATCH( );
277  }
278 
279 
280  Int get_iterations() const {
281  try {
282  return get_node().get_value(sampling_iterations_);
283  } RMF_DECORATOR_CATCH( );
284  }
285  Int get_frame_iterations() const {
286  try {
287  return get_node().get_frame_value(sampling_iterations_);
288  } RMF_DECORATOR_CATCH( );
289  }
290  Int get_static_iterations() const {
291  try {
292  return get_node().get_static_value(sampling_iterations_);
293  } RMF_DECORATOR_CATCH( );
294  }
295 
296 
297  Int get_replicas() const {
298  try {
299  return get_node().get_value(sampling_replicas_);
300  } RMF_DECORATOR_CATCH( );
301  }
302  Int get_frame_replicas() const {
303  try {
304  return get_node().get_frame_value(sampling_replicas_);
305  } RMF_DECORATOR_CATCH( );
306  }
307  Int get_static_replicas() const {
308  try {
309  return get_node().get_static_value(sampling_replicas_);
310  } RMF_DECORATOR_CATCH( );
311  }
312 
313  static std::string get_decorator_type_name() {
314  return "SampleProvenanceConst";
315  }
316  RMF_SHOWABLE(SampleProvenanceConst, "SampleProvenance: " << get_node());
317  };
318  /** See also SampleProvenanceFactory.
319  */
321  friend class SampleProvenanceFactory;
323  StringKey sampling_method,
324 IntKey sampling_frames,
325 IntKey sampling_iterations,
326 IntKey sampling_replicas):
327  SampleProvenanceConst(nh, sampling_method,
328 sampling_frames,
329 sampling_iterations,
330 sampling_replicas) {
331  }
332  public:
333 
334  void set_method(String v) {
335  try {
336  get_node().set_value(sampling_method_, v);
337  } RMF_DECORATOR_CATCH( );
338  }
339  void set_frame_method(String v) {
340  try {
341  get_node().set_frame_value(sampling_method_, v);
342  } RMF_DECORATOR_CATCH( );
343  }
344  void set_static_method(String v) {
345  try {
346  get_node().set_static_value(sampling_method_, v);
347  } RMF_DECORATOR_CATCH( );
348  }
349 
350 
351  void set_frames(Int v) {
352  try {
353  get_node().set_value(sampling_frames_, v);
354  } RMF_DECORATOR_CATCH( );
355  }
356  void set_frame_frames(Int v) {
357  try {
358  get_node().set_frame_value(sampling_frames_, v);
359  } RMF_DECORATOR_CATCH( );
360  }
361  void set_static_frames(Int v) {
362  try {
363  get_node().set_static_value(sampling_frames_, v);
364  } RMF_DECORATOR_CATCH( );
365  }
366 
367 
368  void set_iterations(Int v) {
369  try {
370  get_node().set_value(sampling_iterations_, v);
371  } RMF_DECORATOR_CATCH( );
372  }
373  void set_frame_iterations(Int v) {
374  try {
375  get_node().set_frame_value(sampling_iterations_, v);
376  } RMF_DECORATOR_CATCH( );
377  }
378  void set_static_iterations(Int v) {
379  try {
380  get_node().set_static_value(sampling_iterations_, v);
381  } RMF_DECORATOR_CATCH( );
382  }
383 
384 
385  void set_replicas(Int v) {
386  try {
387  get_node().set_value(sampling_replicas_, v);
388  } RMF_DECORATOR_CATCH( );
389  }
390  void set_frame_replicas(Int v) {
391  try {
392  get_node().set_frame_value(sampling_replicas_, v);
393  } RMF_DECORATOR_CATCH( );
394  }
395  void set_static_replicas(Int v) {
396  try {
397  get_node().set_static_value(sampling_replicas_, v);
398  } RMF_DECORATOR_CATCH( );
399  }
400 
401  static std::string get_decorator_type_name() {
402  return "SampleProvenance";
403  }
404  };
405 
406 
407  /** Create decorators of type SampleProvenance.
408  */
410  Category cat_;
411 StringKey sampling_method_;
412 IntKey sampling_frames_;
413 IntKey sampling_iterations_;
414 IntKey sampling_replicas_;
415 
416 
417 
418 
419  public:
421  cat_(fh.get_category("provenance")),
422  sampling_method_(fh.get_key<StringTag>(cat_, "sampling method")), sampling_frames_(fh.get_key<IntTag>(cat_, "sampling frames")), sampling_iterations_(fh.get_key<IntTag>(cat_, "sampling iterations")), sampling_replicas_(fh.get_key<IntTag>(cat_, "sampling replicas")) {
423  }
425  cat_(fh.get_category("provenance")),
426  sampling_method_(fh.get_key<StringTag>(cat_, "sampling method")), sampling_frames_(fh.get_key<IntTag>(cat_, "sampling frames")), sampling_iterations_(fh.get_key<IntTag>(cat_, "sampling iterations")), sampling_replicas_(fh.get_key<IntTag>(cat_, "sampling replicas")) {
427  }
428  /** Get a SampleProvenanceConst for nh.*/
430  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
431  + boost::lexical_cast<std::string>(nh.get_type())
432  + "\" in decorator type SampleProvenance");
433  return SampleProvenanceConst(nh, sampling_method_,
434 sampling_frames_,
435 sampling_iterations_,
436 sampling_replicas_);
437  }
438  /** Get a SampleProvenance for nh.*/
439  SampleProvenance get(NodeHandle nh) const {
440  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
441  + boost::lexical_cast<std::string>(nh.get_type())
442  + "\" in decorator type SampleProvenance");
443  return SampleProvenance(nh, sampling_method_,
444 sampling_frames_,
445 sampling_iterations_,
446 sampling_replicas_);
447  }
448  /** Check whether nh has all the attributes required to be a
449  SampleProvenanceConst.*/
450  bool get_is(NodeConstHandle nh) const {
451  return (nh.get_type() == RMF::PROVENANCE)
452  && !nh.get_value(sampling_method_).get_is_null();
453  }
454  bool get_is_static(NodeConstHandle nh) const {
455  return (nh.get_type() == RMF::PROVENANCE)
456  && !nh.get_static_value(sampling_method_).get_is_null()
457  && !nh.get_static_value(sampling_frames_).get_is_null()
458  && !nh.get_static_value(sampling_iterations_).get_is_null()
459  && !nh.get_static_value(sampling_replicas_).get_is_null();
460  }
461  RMF_SHOWABLE(SampleProvenanceFactory, "SampleProvenanceFactory");
462  };
463  #ifndef RMF_DOXYGEN
464 struct SampleProvenanceConstFactory: public SampleProvenanceFactory {
465  SampleProvenanceConstFactory(FileConstHandle fh):
466  SampleProvenanceFactory(fh) {
467  }
468  SampleProvenanceConstFactory(FileHandle fh):
469  SampleProvenanceFactory(fh) {
470  }
471 
472 };
473  #endif
474 
475 
476 
477 
478  /** See also CombineProvenance and CombineProvenanceFactory.
479  */
481  friend class CombineProvenanceFactory;
482  protected:
483  IntKey combined_runs_;
484 IntKey combined_frames_;
486  IntKey combined_runs,
487 IntKey combined_frames):
488  Decorator(nh),
489 combined_runs_(combined_runs),
490 combined_frames_(combined_frames) {
491  }
492  public:
493 
494  Int get_runs() const {
495  try {
496  return get_node().get_value(combined_runs_);
497  } RMF_DECORATOR_CATCH( );
498  }
499  Int get_frame_runs() const {
500  try {
501  return get_node().get_frame_value(combined_runs_);
502  } RMF_DECORATOR_CATCH( );
503  }
504  Int get_static_runs() const {
505  try {
506  return get_node().get_static_value(combined_runs_);
507  } RMF_DECORATOR_CATCH( );
508  }
509 
510 
511  Int get_frames() const {
512  try {
513  return get_node().get_value(combined_frames_);
514  } RMF_DECORATOR_CATCH( );
515  }
516  Int get_frame_frames() const {
517  try {
518  return get_node().get_frame_value(combined_frames_);
519  } RMF_DECORATOR_CATCH( );
520  }
521  Int get_static_frames() const {
522  try {
523  return get_node().get_static_value(combined_frames_);
524  } RMF_DECORATOR_CATCH( );
525  }
526 
527  static std::string get_decorator_type_name() {
528  return "CombineProvenanceConst";
529  }
530  RMF_SHOWABLE(CombineProvenanceConst, "CombineProvenance: " << get_node());
531  };
532  /** See also CombineProvenanceFactory.
533  */
535  friend class CombineProvenanceFactory;
537  IntKey combined_runs,
538 IntKey combined_frames):
539  CombineProvenanceConst(nh, combined_runs,
540 combined_frames) {
541  }
542  public:
543 
544  void set_runs(Int v) {
545  try {
546  get_node().set_value(combined_runs_, v);
547  } RMF_DECORATOR_CATCH( );
548  }
549  void set_frame_runs(Int v) {
550  try {
551  get_node().set_frame_value(combined_runs_, v);
552  } RMF_DECORATOR_CATCH( );
553  }
554  void set_static_runs(Int v) {
555  try {
556  get_node().set_static_value(combined_runs_, v);
557  } RMF_DECORATOR_CATCH( );
558  }
559 
560 
561  void set_frames(Int v) {
562  try {
563  get_node().set_value(combined_frames_, v);
564  } RMF_DECORATOR_CATCH( );
565  }
566  void set_frame_frames(Int v) {
567  try {
568  get_node().set_frame_value(combined_frames_, v);
569  } RMF_DECORATOR_CATCH( );
570  }
571  void set_static_frames(Int v) {
572  try {
573  get_node().set_static_value(combined_frames_, v);
574  } RMF_DECORATOR_CATCH( );
575  }
576 
577  static std::string get_decorator_type_name() {
578  return "CombineProvenance";
579  }
580  };
581 
582 
583  /** Create decorators of type CombineProvenance.
584  */
586  Category cat_;
587 IntKey combined_runs_;
588 IntKey combined_frames_;
589 
590 
591  public:
593  cat_(fh.get_category("provenance")),
594  combined_runs_(fh.get_key<IntTag>(cat_, "combined runs")), combined_frames_(fh.get_key<IntTag>(cat_, "combined frames")) {
595  }
597  cat_(fh.get_category("provenance")),
598  combined_runs_(fh.get_key<IntTag>(cat_, "combined runs")), combined_frames_(fh.get_key<IntTag>(cat_, "combined frames")) {
599  }
600  /** Get a CombineProvenanceConst for nh.*/
602  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
603  + boost::lexical_cast<std::string>(nh.get_type())
604  + "\" in decorator type CombineProvenance");
605  return CombineProvenanceConst(nh, combined_runs_,
606 combined_frames_);
607  }
608  /** Get a CombineProvenance for nh.*/
610  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
611  + boost::lexical_cast<std::string>(nh.get_type())
612  + "\" in decorator type CombineProvenance");
613  return CombineProvenance(nh, combined_runs_,
614 combined_frames_);
615  }
616  /** Check whether nh has all the attributes required to be a
617  CombineProvenanceConst.*/
618  bool get_is(NodeConstHandle nh) const {
619  return (nh.get_type() == RMF::PROVENANCE)
620  && !nh.get_value(combined_runs_).get_is_null();
621  }
622  bool get_is_static(NodeConstHandle nh) const {
623  return (nh.get_type() == RMF::PROVENANCE)
624  && !nh.get_static_value(combined_runs_).get_is_null()
625  && !nh.get_static_value(combined_frames_).get_is_null();
626  }
627  RMF_SHOWABLE(CombineProvenanceFactory, "CombineProvenanceFactory");
628  };
629  #ifndef RMF_DOXYGEN
630 struct CombineProvenanceConstFactory: public CombineProvenanceFactory {
631  CombineProvenanceConstFactory(FileConstHandle fh):
632  CombineProvenanceFactory(fh) {
633  }
634  CombineProvenanceConstFactory(FileHandle fh):
635  CombineProvenanceFactory(fh) {
636  }
637 
638 };
639  #endif
640 
641 
642 
643 
644  /** See also FilterProvenance and FilterProvenanceFactory.
645  */
647  friend class FilterProvenanceFactory;
648  protected:
649  StringKey filter_method_;
650 FloatKey filter_threshold_;
651 IntKey filter_frames_;
653  StringKey filter_method,
654 FloatKey filter_threshold,
655 IntKey filter_frames):
656  Decorator(nh),
657 filter_method_(filter_method),
658 filter_threshold_(filter_threshold),
659 filter_frames_(filter_frames) {
660  }
661  public:
662 
663  String get_method() const {
664  try {
665  return get_node().get_value(filter_method_);
666  } RMF_DECORATOR_CATCH( );
667  }
668  String get_frame_method() const {
669  try {
670  return get_node().get_frame_value(filter_method_);
671  } RMF_DECORATOR_CATCH( );
672  }
673  String get_static_method() const {
674  try {
675  return get_node().get_static_value(filter_method_);
676  } RMF_DECORATOR_CATCH( );
677  }
678 
679 
680  Float get_threshold() const {
681  try {
682  return get_node().get_value(filter_threshold_);
683  } RMF_DECORATOR_CATCH( );
684  }
685  Float get_frame_threshold() const {
686  try {
687  return get_node().get_frame_value(filter_threshold_);
688  } RMF_DECORATOR_CATCH( );
689  }
690  Float get_static_threshold() const {
691  try {
692  return get_node().get_static_value(filter_threshold_);
693  } RMF_DECORATOR_CATCH( );
694  }
695 
696 
697  Int get_frames() const {
698  try {
699  return get_node().get_value(filter_frames_);
700  } RMF_DECORATOR_CATCH( );
701  }
702  Int get_frame_frames() const {
703  try {
704  return get_node().get_frame_value(filter_frames_);
705  } RMF_DECORATOR_CATCH( );
706  }
707  Int get_static_frames() const {
708  try {
709  return get_node().get_static_value(filter_frames_);
710  } RMF_DECORATOR_CATCH( );
711  }
712 
713  static std::string get_decorator_type_name() {
714  return "FilterProvenanceConst";
715  }
716  RMF_SHOWABLE(FilterProvenanceConst, "FilterProvenance: " << get_node());
717  };
718  /** See also FilterProvenanceFactory.
719  */
721  friend class FilterProvenanceFactory;
723  StringKey filter_method,
724 FloatKey filter_threshold,
725 IntKey filter_frames):
726  FilterProvenanceConst(nh, filter_method,
727 filter_threshold,
728 filter_frames) {
729  }
730  public:
731 
732  void set_method(String v) {
733  try {
734  get_node().set_value(filter_method_, v);
735  } RMF_DECORATOR_CATCH( );
736  }
737  void set_frame_method(String v) {
738  try {
739  get_node().set_frame_value(filter_method_, v);
740  } RMF_DECORATOR_CATCH( );
741  }
742  void set_static_method(String v) {
743  try {
744  get_node().set_static_value(filter_method_, v);
745  } RMF_DECORATOR_CATCH( );
746  }
747 
748 
749  void set_threshold(Float v) {
750  try {
751  get_node().set_value(filter_threshold_, v);
752  } RMF_DECORATOR_CATCH( );
753  }
754  void set_frame_threshold(Float v) {
755  try {
756  get_node().set_frame_value(filter_threshold_, v);
757  } RMF_DECORATOR_CATCH( );
758  }
759  void set_static_threshold(Float v) {
760  try {
761  get_node().set_static_value(filter_threshold_, v);
762  } RMF_DECORATOR_CATCH( );
763  }
764 
765 
766  void set_frames(Int v) {
767  try {
768  get_node().set_value(filter_frames_, v);
769  } RMF_DECORATOR_CATCH( );
770  }
771  void set_frame_frames(Int v) {
772  try {
773  get_node().set_frame_value(filter_frames_, v);
774  } RMF_DECORATOR_CATCH( );
775  }
776  void set_static_frames(Int v) {
777  try {
778  get_node().set_static_value(filter_frames_, v);
779  } RMF_DECORATOR_CATCH( );
780  }
781 
782  static std::string get_decorator_type_name() {
783  return "FilterProvenance";
784  }
785  };
786 
787 
788  /** Create decorators of type FilterProvenance.
789  */
791  Category cat_;
792 StringKey filter_method_;
793 FloatKey filter_threshold_;
794 IntKey filter_frames_;
795 
796 
797 
798  public:
800  cat_(fh.get_category("provenance")),
801  filter_method_(fh.get_key<StringTag>(cat_, "filter method")), filter_threshold_(fh.get_key<FloatTag>(cat_, "filter threshold")), filter_frames_(fh.get_key<IntTag>(cat_, "filter frames")) {
802  }
804  cat_(fh.get_category("provenance")),
805  filter_method_(fh.get_key<StringTag>(cat_, "filter method")), filter_threshold_(fh.get_key<FloatTag>(cat_, "filter threshold")), filter_frames_(fh.get_key<IntTag>(cat_, "filter frames")) {
806  }
807  /** Get a FilterProvenanceConst for nh.*/
809  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
810  + boost::lexical_cast<std::string>(nh.get_type())
811  + "\" in decorator type FilterProvenance");
812  return FilterProvenanceConst(nh, filter_method_,
813 filter_threshold_,
814 filter_frames_);
815  }
816  /** Get a FilterProvenance for nh.*/
817  FilterProvenance get(NodeHandle nh) const {
818  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
819  + boost::lexical_cast<std::string>(nh.get_type())
820  + "\" in decorator type FilterProvenance");
821  return FilterProvenance(nh, filter_method_,
822 filter_threshold_,
823 filter_frames_);
824  }
825  /** Check whether nh has all the attributes required to be a
826  FilterProvenanceConst.*/
827  bool get_is(NodeConstHandle nh) const {
828  return (nh.get_type() == RMF::PROVENANCE)
829  && !nh.get_value(filter_method_).get_is_null();
830  }
831  bool get_is_static(NodeConstHandle nh) const {
832  return (nh.get_type() == RMF::PROVENANCE)
833  && !nh.get_static_value(filter_method_).get_is_null()
834  && !nh.get_static_value(filter_threshold_).get_is_null()
835  && !nh.get_static_value(filter_frames_).get_is_null();
836  }
837  RMF_SHOWABLE(FilterProvenanceFactory, "FilterProvenanceFactory");
838  };
839  #ifndef RMF_DOXYGEN
840 struct FilterProvenanceConstFactory: public FilterProvenanceFactory {
841  FilterProvenanceConstFactory(FileConstHandle fh):
842  FilterProvenanceFactory(fh) {
843  }
844  FilterProvenanceConstFactory(FileHandle fh):
845  FilterProvenanceFactory(fh) {
846  }
847 
848 };
849  #endif
850 
851 
852 
853 
854  /** See also ClusterProvenance and ClusterProvenanceFactory.
855  */
857  friend class ClusterProvenanceFactory;
858  protected:
859  IntKey cluster_members_;
860 FloatKey cluster_precision_;
861 StringKey cluster_density_;
863  IntKey cluster_members,
864 FloatKey cluster_precision,
865 StringKey cluster_density):
866  Decorator(nh),
867 cluster_members_(cluster_members),
868 cluster_precision_(cluster_precision),
869 cluster_density_(cluster_density) {
870  }
871  public:
872 
873  Int get_members() const {
874  try {
875  return get_node().get_value(cluster_members_);
876  } RMF_DECORATOR_CATCH( );
877  }
878  Int get_frame_members() const {
879  try {
880  return get_node().get_frame_value(cluster_members_);
881  } RMF_DECORATOR_CATCH( );
882  }
883  Int get_static_members() const {
884  try {
885  return get_node().get_static_value(cluster_members_);
886  } RMF_DECORATOR_CATCH( );
887  }
888 
889 
890  Float get_precision() const {
891  try {
892  if (!get_node().get_has_value(cluster_precision_)) return 0.0;
893 return get_node().get_value(cluster_precision_);
894  } RMF_DECORATOR_CATCH( );
895  }
896  Float get_frame_precision() const {
897  try {
898  if (!get_node().get_has_value(cluster_precision_)) return 0.0;
899 return get_node().get_frame_value(cluster_precision_);
900  } RMF_DECORATOR_CATCH( );
901  }
902  Float get_static_precision() const {
903  try {
904  if (!get_node().get_has_value(cluster_precision_)) return 0.0;
905 return get_node().get_static_value(cluster_precision_);
906  } RMF_DECORATOR_CATCH( );
907  }
908 
909 
910  String get_density() const {
911  try {
912  if (!get_node().get_has_value(cluster_density_)) {
913  return "";
914  } else {
915  String relpath = get_node().get_value(cluster_density_);
916  String filename = get_node().get_file().get_path();
917  return internal::get_absolute_path(filename, relpath);
918  }
919  } RMF_DECORATOR_CATCH( );
920  }
921 
922  static std::string get_decorator_type_name() {
923  return "ClusterProvenanceConst";
924  }
925  RMF_SHOWABLE(ClusterProvenanceConst, "ClusterProvenance: " << get_node());
926  };
927  /** See also ClusterProvenanceFactory.
928  */
930  friend class ClusterProvenanceFactory;
932  IntKey cluster_members,
933 FloatKey cluster_precision,
934 StringKey cluster_density):
935  ClusterProvenanceConst(nh, cluster_members,
936 cluster_precision,
937 cluster_density) {
938  }
939  public:
940 
941  void set_members(Int v) {
942  try {
943  get_node().set_value(cluster_members_, v);
944  } RMF_DECORATOR_CATCH( );
945  }
946  void set_frame_members(Int v) {
947  try {
948  get_node().set_frame_value(cluster_members_, v);
949  } RMF_DECORATOR_CATCH( );
950  }
951  void set_static_members(Int v) {
952  try {
953  get_node().set_static_value(cluster_members_, v);
954  } RMF_DECORATOR_CATCH( );
955  }
956 
957 
958  void set_precision(Float v) {
959  try {
960  get_node().set_value(cluster_precision_, v);
961  } RMF_DECORATOR_CATCH( );
962  }
963  void set_frame_precision(Float v) {
964  try {
965  get_node().set_frame_value(cluster_precision_, v);
966  } RMF_DECORATOR_CATCH( );
967  }
968  void set_static_precision(Float v) {
969  try {
970  get_node().set_static_value(cluster_precision_, v);
971  } RMF_DECORATOR_CATCH( );
972  }
973 
974 
975  void set_density(String path) {
976  try {
977  if (path.empty()) {
978  get_node().set_value(cluster_density_, path);
979  } else {
980  String filename = get_node().get_file().get_path();
981  String relpath = internal::get_relative_path(filename, path);
982  get_node().set_value(cluster_density_, relpath);
983  }
984  } RMF_DECORATOR_CATCH( );
985  }
986 
987  static std::string get_decorator_type_name() {
988  return "ClusterProvenance";
989  }
990  };
991 
992 
993  /** Create decorators of type ClusterProvenance.
994  */
996  Category cat_;
997 IntKey cluster_members_;
998 FloatKey cluster_precision_;
999 StringKey cluster_density_;
1000 
1001 
1002 
1003  public:
1005  cat_(fh.get_category("provenance")),
1006  cluster_members_(fh.get_key<IntTag>(cat_, "cluster members")), cluster_precision_(fh.get_key<FloatTag>(cat_, "cluster precision")), cluster_density_(fh.get_key<StringTag>(cat_, "cluster density")) {
1007  }
1009  cat_(fh.get_category("provenance")),
1010  cluster_members_(fh.get_key<IntTag>(cat_, "cluster members")), cluster_precision_(fh.get_key<FloatTag>(cat_, "cluster precision")), cluster_density_(fh.get_key<StringTag>(cat_, "cluster density")) {
1011  }
1012  /** Get a ClusterProvenanceConst for nh.*/
1014  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
1015  + boost::lexical_cast<std::string>(nh.get_type())
1016  + "\" in decorator type ClusterProvenance");
1017  return ClusterProvenanceConst(nh, cluster_members_,
1018 cluster_precision_,
1019 cluster_density_);
1020  }
1021  /** Get a ClusterProvenance for nh.*/
1023  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
1024  + boost::lexical_cast<std::string>(nh.get_type())
1025  + "\" in decorator type ClusterProvenance");
1026  return ClusterProvenance(nh, cluster_members_,
1027 cluster_precision_,
1028 cluster_density_);
1029  }
1030  /** Check whether nh has all the attributes required to be a
1031  ClusterProvenanceConst.*/
1032  bool get_is(NodeConstHandle nh) const {
1033  return (nh.get_type() == RMF::PROVENANCE)
1034  && !nh.get_value(cluster_members_).get_is_null();
1035  }
1036  bool get_is_static(NodeConstHandle nh) const {
1037  return (nh.get_type() == RMF::PROVENANCE)
1038  && !nh.get_static_value(cluster_members_).get_is_null()
1039  && !nh.get_static_value(cluster_density_).get_is_null();
1040  }
1041  RMF_SHOWABLE(ClusterProvenanceFactory, "ClusterProvenanceFactory");
1042  };
1043  #ifndef RMF_DOXYGEN
1044 struct ClusterProvenanceConstFactory: public ClusterProvenanceFactory {
1045  ClusterProvenanceConstFactory(FileConstHandle fh):
1046  ClusterProvenanceFactory(fh) {
1047  }
1048  ClusterProvenanceConstFactory(FileHandle fh):
1049  ClusterProvenanceFactory(fh) {
1050  }
1051 
1052 };
1053  #endif
1054 
1055 
1056 
1057 
1058  /** See also ScriptProvenance and ScriptProvenanceFactory.
1059  */
1061  friend class ScriptProvenanceFactory;
1062  protected:
1063  StringKey script_filename_;
1065  StringKey script_filename):
1066  Decorator(nh),
1067 script_filename_(script_filename) {
1068  }
1069  public:
1070 
1071  String get_filename() const {
1072  try {
1073  String relpath = get_node().get_value(script_filename_);
1074  String filename = get_node().get_file().get_path();
1075  return internal::get_absolute_path(filename, relpath);
1076  } RMF_DECORATOR_CATCH( );
1077  }
1078 
1079  static std::string get_decorator_type_name() {
1080  return "ScriptProvenanceConst";
1081  }
1082  RMF_SHOWABLE(ScriptProvenanceConst, "ScriptProvenance: " << get_node());
1083  };
1084  /** See also ScriptProvenanceFactory.
1085  */
1087  friend class ScriptProvenanceFactory;
1089  StringKey script_filename):
1090  ScriptProvenanceConst(nh, script_filename) {
1091  }
1092  public:
1093 
1094  void set_filename(String path) {
1095  try {
1096  String filename = get_node().get_file().get_path();
1097  String relpath = internal::get_relative_path(filename, path);
1098  get_node().set_value(script_filename_, relpath);
1099  } RMF_DECORATOR_CATCH( );
1100  }
1101 
1102  static std::string get_decorator_type_name() {
1103  return "ScriptProvenance";
1104  }
1105  };
1106 
1107 
1108  /** Create decorators of type ScriptProvenance.
1109  */
1111  Category cat_;
1112 StringKey script_filename_;
1113 
1114  public:
1116  cat_(fh.get_category("provenance")),
1117  script_filename_(fh.get_key<StringTag>(cat_, "script filename")) {
1118  }
1120  cat_(fh.get_category("provenance")),
1121  script_filename_(fh.get_key<StringTag>(cat_, "script filename")) {
1122  }
1123  /** Get a ScriptProvenanceConst for nh.*/
1125  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
1126  + boost::lexical_cast<std::string>(nh.get_type())
1127  + "\" in decorator type ScriptProvenance");
1128  return ScriptProvenanceConst(nh, script_filename_);
1129  }
1130  /** Get a ScriptProvenance for nh.*/
1132  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
1133  + boost::lexical_cast<std::string>(nh.get_type())
1134  + "\" in decorator type ScriptProvenance");
1135  return ScriptProvenance(nh, script_filename_);
1136  }
1137  /** Check whether nh has all the attributes required to be a
1138  ScriptProvenanceConst.*/
1139  bool get_is(NodeConstHandle nh) const {
1140  return (nh.get_type() == RMF::PROVENANCE)
1141  && !nh.get_value(script_filename_).get_is_null();
1142  }
1143  bool get_is_static(NodeConstHandle nh) const {
1144  return (nh.get_type() == RMF::PROVENANCE)
1145  && !nh.get_static_value(script_filename_).get_is_null();
1146  }
1147  RMF_SHOWABLE(ScriptProvenanceFactory, "ScriptProvenanceFactory");
1148  };
1149  #ifndef RMF_DOXYGEN
1150 struct ScriptProvenanceConstFactory: public ScriptProvenanceFactory {
1151  ScriptProvenanceConstFactory(FileConstHandle fh):
1152  ScriptProvenanceFactory(fh) {
1153  }
1154  ScriptProvenanceConstFactory(FileHandle fh):
1155  ScriptProvenanceFactory(fh) {
1156  }
1157 
1158 };
1159  #endif
1160 
1161 
1162 
1163 
1164  /** See also SoftwareProvenance and SoftwareProvenanceFactory.
1165  */
1167  friend class SoftwareProvenanceFactory;
1168  protected:
1169  StringKey software_name_;
1170 StringKey software_version_;
1171 StringKey software_location_;
1173  StringKey software_name,
1174 StringKey software_version,
1175 StringKey software_location):
1176  Decorator(nh),
1177 software_name_(software_name),
1178 software_version_(software_version),
1179 software_location_(software_location) {
1180  }
1181  public:
1182 
1183  String get_name() const {
1184  try {
1185  return get_node().get_value(software_name_);
1186  } RMF_DECORATOR_CATCH( );
1187  }
1188  String get_frame_name() const {
1189  try {
1190  return get_node().get_frame_value(software_name_);
1191  } RMF_DECORATOR_CATCH( );
1192  }
1193  String get_static_name() const {
1194  try {
1195  return get_node().get_static_value(software_name_);
1196  } RMF_DECORATOR_CATCH( );
1197  }
1198 
1199 
1200  String get_version() const {
1201  try {
1202  return get_node().get_value(software_version_);
1203  } RMF_DECORATOR_CATCH( );
1204  }
1205  String get_frame_version() const {
1206  try {
1207  return get_node().get_frame_value(software_version_);
1208  } RMF_DECORATOR_CATCH( );
1209  }
1210  String get_static_version() const {
1211  try {
1212  return get_node().get_static_value(software_version_);
1213  } RMF_DECORATOR_CATCH( );
1214  }
1215 
1216 
1217  String get_location() const {
1218  try {
1219  return get_node().get_value(software_location_);
1220  } RMF_DECORATOR_CATCH( );
1221  }
1222  String get_frame_location() const {
1223  try {
1224  return get_node().get_frame_value(software_location_);
1225  } RMF_DECORATOR_CATCH( );
1226  }
1227  String get_static_location() const {
1228  try {
1229  return get_node().get_static_value(software_location_);
1230  } RMF_DECORATOR_CATCH( );
1231  }
1232 
1233  static std::string get_decorator_type_name() {
1234  return "SoftwareProvenanceConst";
1235  }
1236  RMF_SHOWABLE(SoftwareProvenanceConst, "SoftwareProvenance: " << get_node());
1237  };
1238  /** See also SoftwareProvenanceFactory.
1239  */
1241  friend class SoftwareProvenanceFactory;
1243  StringKey software_name,
1244 StringKey software_version,
1245 StringKey software_location):
1246  SoftwareProvenanceConst(nh, software_name,
1247 software_version,
1248 software_location) {
1249  }
1250  public:
1251 
1252  void set_name(String v) {
1253  try {
1254  get_node().set_value(software_name_, v);
1255  } RMF_DECORATOR_CATCH( );
1256  }
1257  void set_frame_name(String v) {
1258  try {
1259  get_node().set_frame_value(software_name_, v);
1260  } RMF_DECORATOR_CATCH( );
1261  }
1262  void set_static_name(String v) {
1263  try {
1264  get_node().set_static_value(software_name_, v);
1265  } RMF_DECORATOR_CATCH( );
1266  }
1267 
1268 
1269  void set_version(String v) {
1270  try {
1271  get_node().set_value(software_version_, v);
1272  } RMF_DECORATOR_CATCH( );
1273  }
1274  void set_frame_version(String v) {
1275  try {
1276  get_node().set_frame_value(software_version_, v);
1277  } RMF_DECORATOR_CATCH( );
1278  }
1279  void set_static_version(String v) {
1280  try {
1281  get_node().set_static_value(software_version_, v);
1282  } RMF_DECORATOR_CATCH( );
1283  }
1284 
1285 
1286  void set_location(String v) {
1287  try {
1288  get_node().set_value(software_location_, v);
1289  } RMF_DECORATOR_CATCH( );
1290  }
1291  void set_frame_location(String v) {
1292  try {
1293  get_node().set_frame_value(software_location_, v);
1294  } RMF_DECORATOR_CATCH( );
1295  }
1296  void set_static_location(String v) {
1297  try {
1298  get_node().set_static_value(software_location_, v);
1299  } RMF_DECORATOR_CATCH( );
1300  }
1301 
1302  static std::string get_decorator_type_name() {
1303  return "SoftwareProvenance";
1304  }
1305  };
1306 
1307 
1308  /** Create decorators of type SoftwareProvenance.
1309  */
1311  Category cat_;
1312 StringKey software_name_;
1313 StringKey software_version_;
1314 StringKey software_location_;
1315 
1316 
1317 
1318  public:
1320  cat_(fh.get_category("provenance")),
1321  software_name_(fh.get_key<StringTag>(cat_, "software name")), software_version_(fh.get_key<StringTag>(cat_, "software version")), software_location_(fh.get_key<StringTag>(cat_, "software location")) {
1322  }
1324  cat_(fh.get_category("provenance")),
1325  software_name_(fh.get_key<StringTag>(cat_, "software name")), software_version_(fh.get_key<StringTag>(cat_, "software version")), software_location_(fh.get_key<StringTag>(cat_, "software location")) {
1326  }
1327  /** Get a SoftwareProvenanceConst for nh.*/
1329  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
1330  + boost::lexical_cast<std::string>(nh.get_type())
1331  + "\" in decorator type SoftwareProvenance");
1332  return SoftwareProvenanceConst(nh, software_name_,
1333 software_version_,
1334 software_location_);
1335  }
1336  /** Get a SoftwareProvenance for nh.*/
1338  RMF_USAGE_CHECK((nh.get_type() == RMF::PROVENANCE), std::string("Bad node type. Got \"")
1339  + boost::lexical_cast<std::string>(nh.get_type())
1340  + "\" in decorator type SoftwareProvenance");
1341  return SoftwareProvenance(nh, software_name_,
1342 software_version_,
1343 software_location_);
1344  }
1345  /** Check whether nh has all the attributes required to be a
1346  SoftwareProvenanceConst.*/
1347  bool get_is(NodeConstHandle nh) const {
1348  return (nh.get_type() == RMF::PROVENANCE)
1349  && !nh.get_value(software_name_).get_is_null();
1350  }
1351  bool get_is_static(NodeConstHandle nh) const {
1352  return (nh.get_type() == RMF::PROVENANCE)
1353  && !nh.get_static_value(software_name_).get_is_null()
1354  && !nh.get_static_value(software_version_).get_is_null()
1355  && !nh.get_static_value(software_location_).get_is_null();
1356  }
1357  RMF_SHOWABLE(SoftwareProvenanceFactory, "SoftwareProvenanceFactory");
1358  };
1359  #ifndef RMF_DOXYGEN
1360 struct SoftwareProvenanceConstFactory: public SoftwareProvenanceFactory {
1361  SoftwareProvenanceConstFactory(FileConstHandle fh):
1362  SoftwareProvenanceFactory(fh) {
1363  }
1364  SoftwareProvenanceConstFactory(FileHandle fh):
1365  SoftwareProvenanceFactory(fh) {
1366  }
1367 
1368 };
1369  #endif
1370 
1371 
1372 
1373 } /* namespace decorator */
1374 } /* namespace RMF */
1375 RMF_DISABLE_WARNINGS
1376 
1377 #endif /* RMF_PROVENANCE_DECORATORS_H */
Mostly empty base classes for decorators and factories.
A handle for a particular node in the hierarchy.
Definition: NodeHandle.h:60
float Float
Definition: types.h:33
bool get_is(NodeConstHandle nh) const
Definition: provenance.h:450
bool get_is(NodeConstHandle nh) const
Definition: provenance.h:198
The base class for decorators.
Definition: Decorator.h:29
NodeType get_type() const
get the type of this node
Various constants.
A handle for a particular node in a read-only hierarchy.
A handle for a read-only RMF file.
bool get_is(NodeConstHandle nh) const
Definition: provenance.h:827
const NodeType PROVENANCE
Represent the process by which a structure was created.
void set_value(ID< Tag > k, typename Tag::ArgumentType v) const
Definition: NodeHandle.h:115
A handle for an RMF file.
Definition: FileHandle.h:54
bool get_is(NodeConstHandle nh) const
Definition: provenance.h:1347
The base class for Factories.
Definition: Decorator.h:46
bool get_is(NodeConstHandle nh) const
Definition: provenance.h:1139
Declaration for RMF::FileHandle.
Represent coordinates.
Declaration of NodeHandle.
void set_static_value(ID< Tag > k, typename Tag::ArgumentType v) const
set the value of the attribute k for all frames.
Definition: NodeHandle.h:122
std::string String
Definition: types.h:39
ID< Tag > get_key(Category category, std::string name) const
int Int
Definition: types.h:29
bool get_is(NodeConstHandle nh) const
Definition: provenance.h:618
Various general useful macros for IMP.
bool get_is(NodeConstHandle nh) const
Definition: provenance.h:1032
void set_frame_value(ID< Tag > k, typename Tag::ArgumentType v) const
set the value of the attribute k for this node on the current frame.
Definition: NodeHandle.h:103