import source from 1.3.40
[external/swig.git] / Examples / ruby / free_function / example.h
1 #ifndef _EXAMPLE_H_
2 #define _EXAMPLE_H_
3
4 #include <vector>
5 #include <string>
6
7 class Animal
8 {
9 protected:
10         std::string name_;
11 public:
12         // Construct an animal with a name
13         Animal(const char* name);
14
15         // Destruct an animal
16         ~Animal();
17
18         // Return the animal's name
19         const char* get_name() const;
20 };
21         
22 class Zoo
23 {
24 private:
25         typedef std::vector<Animal*> AnimalsType;
26         typedef AnimalsType::iterator IterType;
27 protected:
28         AnimalsType animals;
29 public:
30         Zoo();
31         ~Zoo(); 
32
33         /* Create a new animal */
34         static Animal* create_animal(const char* name);
35
36         /* Add a new animal to the zoo */
37         void add_animal(Animal* animal);
38         
39         /* Remove an animal from the zoo */
40         Animal* remove_animal(size_t i);
41
42         /* Return the number of animals in the zoo */
43         size_t get_num_animals() const;
44         
45         /* Return a pointer to the ith animal */
46         Animal* get_animal(size_t i) const;
47 };
48
49 #endif /*_EXAMPLE_H_*/