[cig-commits] [commit] master: Add Python event accessor (5f487d0)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Oct 8 17:06:21 PDT 2014


Repository : https://github.com/geodynamics/vc

On branch  : master
Link       : https://github.com/geodynamics/vc/compare/23464fca3efa2b6ad7ee0ce8f60c225b18b49741...e4325192ad1118379f46ba66899cb98143d09e04

>---------------------------------------------------------------

commit 5f487d0166eba9fb7ae02f4c829bbb586164bd28
Author: Eric Heien <emheien at ucdavis.edu>
Date:   Tue Sep 30 09:34:39 2014 -0700

    Add Python event accessor


>---------------------------------------------------------------

5f487d0166eba9fb7ae02f4c829bbb586164bd28
 quakelib/python/quakelib.i |  5 +++++
 quakelib/src/QuakeLibIO.h  | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/quakelib/python/quakelib.i b/quakelib/python/quakelib.i
index e67509e..be8ac40 100644
--- a/quakelib/python/quakelib.i
+++ b/quakelib/python/quakelib.i
@@ -53,6 +53,11 @@ using namespace quakelib;
 	void __setitem__(unsigned int i, TensorRow<3> new_val) throw(std::out_of_range) { (*$self)[i] = new_val; };
 };
 
+%extend quakelib::ModelEventSet {
+    ModelEvent __getitem__(unsigned int i) throw(std::out_of_range) { return (*$self)[i]; };
+	void __setitem__(unsigned int i, ModelEvent new_val) throw(std::out_of_range) { (*$self)[i] = new_val; };
+};
+
 %template(RectBound2) quakelib::RectBound<2>;
 %template(RectBound3) quakelib::RectBound<3>;
 
diff --git a/quakelib/src/QuakeLibIO.h b/quakelib/src/QuakeLibIO.h
index e8a8f68..886583f 100644
--- a/quakelib/src/QuakeLibIO.h
+++ b/quakelib/src/QuakeLibIO.h
@@ -943,6 +943,20 @@ namespace quakelib {
             return _events.end();
         };
         
+        unsigned int size(void) const {
+            return _events.size();
+        }
+        
+        ModelEvent &operator[](const unsigned int ind) throw(std::out_of_range) {
+            if (ind >= _events.size()) throw std::out_of_range("ModelEventSet[]");
+            return _events[ind];
+        };
+        
+        const ModelEvent &operator[](const unsigned int ind) const throw(std::out_of_range) {
+            if (ind >= _events.size()) throw std::out_of_range("ModelEventSet[]");
+            return _events[ind];
+        };
+        
         int read_file_ascii(const std::string &event_file_name, const std::string &sweep_file_name);
     };
 }



More information about the CIG-COMMITS mailing list