summaryrefslogtreecommitdiff
path: root/trunk/Examples/ruby/free_function/example.h
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2010-06-02 20:53:17 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2010-06-02 20:53:17 +0000
commit2824b0cbb66e715490e1ef13250bd675d87b32d9 (patch)
treec3bc8d54c6d73f2b7ce08cac34172dbc9f5e5b95 /trunk/Examples/ruby/free_function/example.h
parent289cfef4b4766ff266f3b1bdda8ca3a952e5a047 (diff)
downloadswig-2.0.0.tar.gz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-2.0.0@12089 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'trunk/Examples/ruby/free_function/example.h')
-rw-r--r--trunk/Examples/ruby/free_function/example.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/trunk/Examples/ruby/free_function/example.h b/trunk/Examples/ruby/free_function/example.h
new file mode 100644
index 000000000..933bb3645
--- /dev/null
+++ b/trunk/Examples/ruby/free_function/example.h
@@ -0,0 +1,49 @@
+#ifndef _EXAMPLE_H_
+#define _EXAMPLE_H_
+
+#include <vector>
+#include <string>
+
+class Animal
+{
+protected:
+ std::string name_;
+public:
+ // Construct an animal with a name
+ Animal(const char* name);
+
+ // Destruct an animal
+ ~Animal();
+
+ // Return the animal's name
+ const char* get_name() const;
+};
+
+class Zoo
+{
+private:
+ typedef std::vector<Animal*> AnimalsType;
+ typedef AnimalsType::iterator IterType;
+protected:
+ AnimalsType animals;
+public:
+ Zoo();
+ ~Zoo();
+
+ /* Create a new animal */
+ static Animal* create_animal(const char* name);
+
+ /* Add a new animal to the zoo */
+ void add_animal(Animal* animal);
+
+ /* Remove an animal from the zoo */
+ Animal* remove_animal(size_t i);
+
+ /* Return the number of animals in the zoo */
+ size_t get_num_animals() const;
+
+ /* Return a pointer to the ith animal */
+ Animal* get_animal(size_t i) const;
+};
+
+#endif /*_EXAMPLE_H_*/