00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <pandabase.h>
00021 #include <notify.h>
00022
00023 #include "factory.h"
00024 #include "writableParam.h"
00025 #include "factoryParams.h"
00026 #include "bamWriter.h"
00027 #include "bamReader.h"
00028 #include "pointerTo.h"
00029
00030 #include "typedWritableReferenceCount.h"
00031
00032 #include <ipc_file.h>
00033
00034 class Child;
00035
00036 class Person : public TypedWritableReferenceCount {
00037 public:
00038 void write_datagram(BamWriter*, Datagram&);
00039
00040 static TypedWritable *make_person(const FactoryParams ¶ms);
00041 virtual int complete_pointers(TypedWritable **p_list,
00042 BamReader *manager);
00043 protected:
00044 void fillin(Person*,DatagramIterator&,BamReader*);
00045 public:
00046 enum sex {
00047 MALE,
00048 FEMALE
00049 };
00050
00051 void setBrother(Person* bro) {if (bro->isMale()) _bro = bro;}
00052 void setSister(Person* sis) {if (!sis->isMale()) _sis = sis;}
00053 bool isMale(void) {return myGender == MALE;}
00054
00055 void print_relationships(void);
00056 string name(void) {return _name;}
00057 private:
00058 Person *_bro, *_sis;
00059 sex myGender;
00060 string _name;
00061
00062 public:
00063 Person(void) {}
00064 Person(const string &name, const sex Gender) :
00065 _name(name), myGender(Gender), _bro((Person*)NULL), _sis((Person*)NULL) {
00066
00067 }
00068 virtual ~Person() {
00069
00070 }
00071 static TypeHandle get_class_type() {
00072 return _type_handle;
00073 }
00074 static void init_type() {
00075 TypedWritableReferenceCount::init_type();
00076 register_type(_type_handle, "Person",
00077 TypedWritableReferenceCount::get_class_type());
00078 }
00079 virtual TypeHandle get_type() const {
00080 return get_class_type();
00081 }
00082 virtual TypeHandle force_init_type(void) {
00083 init_type();
00084 return get_class_type();
00085 }
00086
00087 private:
00088 static TypeHandle _type_handle;
00089 };
00090
00091 class Parent : public Person {
00092 public:
00093 void write_datagram(BamWriter*, Datagram&);
00094
00095 static TypedWritable *make_parent(const FactoryParams ¶ms);
00096 virtual int complete_pointers(TypedWritable *p_list,
00097 BamReader *manager);
00098 protected:
00099 void fillin(Parent*,DatagramIterator&,BamReader*);
00100 public:
00101 void setSon(Child*);
00102 void setDaughter(Child*);
00103
00104 void print_relationships(void);
00105
00106 private:
00107 Child *_son, *_daughter;
00108
00109 public:
00110 Parent(void) {}
00111 Parent(const string &name, const sex Gender) : Person(name, Gender) {
00112
00113 }
00114 virtual ~Parent() {
00115
00116 }
00117 static TypeHandle get_class_type() {
00118 return _type_handle;
00119 }
00120 static void init_type() {
00121 Person::init_type();
00122 register_type(_type_handle, "Parent",
00123 Person::get_class_type());
00124 }
00125 virtual TypeHandle get_type() const {
00126 return get_class_type();
00127 }
00128 virtual TypeHandle force_init_type(void) {
00129 init_type();
00130 return get_class_type();
00131 }
00132
00133 private:
00134 static TypeHandle _type_handle;
00135 };
00136
00137 class Child : public Person {
00138 public:
00139 void write_datagram(BamWriter*, Datagram&);
00140
00141 static TypedWritable *make_child(const FactoryParams ¶ms);
00142 virtual int complete_pointers(TypedWritable **p_list,
00143 BamReader *manager);
00144 protected:
00145 void fillin(Child*,DatagramIterator&,BamReader*);
00146 public:
00147 void setFather(Parent*);
00148 void setMother(Parent*);
00149
00150 void print_relationships(void);
00151
00152 private:
00153 Parent *_dad, *_mom;
00154
00155 public:
00156 Child(void) {}
00157 Child(const string &name, const sex Gender) : Person(name, Gender) {
00158
00159 }
00160 virtual ~Child() {
00161
00162 }
00163 static TypeHandle get_class_type() {
00164 return _type_handle;
00165 }
00166 static void init_type() {
00167 Person::init_type();
00168 register_type(_type_handle, "Child", Person::get_class_type());
00169 }
00170 virtual TypeHandle get_type() const {
00171 return get_class_type();
00172 }
00173 virtual TypeHandle force_init_type(void) {
00174 init_type();
00175 return get_class_type();
00176 }
00177
00178 private:
00179 static TypeHandle _type_handle;
00180 };
00181
00182
00183