00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <string>
00015 #include <vos/vos/vos.hh>
00016 #include <vos/metaobjects/misc/hypercard.hh>
00017
00018 #include "vostut8creature.hh"
00019
00020 using namespace std;
00021 using namespace VUtil;
00022 using namespace VOS;
00023
00024
00025
00026
00027 Creature::Creature(VobjectBase* superobject)
00028 : MetaObject(superobject) {
00029 }
00030
00031
00032
00033 const std::string Creature::getVOSType() {
00034 return "tutorial:creature";
00035 }
00036
00037 MetaObject* Creature::new_Creature(VobjectBase* superobject, const std::string& type) {
00038 return new Creature(superobject);
00039 }
00040
00041
00042
00043 void Creature::setGenus(const std::string& value) {
00044 Property::setProperty(*this, "tutorial:genus", value, "string");
00045 }
00046
00047
00048 void Creature::getGenus(std::string& value) {
00049 string t;
00050 Property::getProperty(*this, "tutorial:genus", value, t);
00051 }
00052
00053
00054 void Creature::setSpecies(const std::string& value) {
00055 Property::setProperty(*this, "tutorial:species", value, "string");
00056 }
00057
00058
00059 void Creature::getSpecies(std::string& value) {
00060 string t;
00061 Property::getProperty(*this, "tutorial:species", value, t);
00062 }
00063
00064
00065 void Creature::setCommonName(const std::string& value) {
00066 Property::setProperty(*this, "tutorial:common-name", value, "string");
00067 }
00068
00069
00070 void Creature::getCommonName(std::string& value) {
00071 string t;
00072 Property::getProperty(*this, "tutorial:common-name", value, t);
00073 }
00074
00075
00076 void Creature::setDescription(const std::string& value, const std::string& datatype) {
00077 Property::setProperty(*this, "tutorial:description", value, datatype);
00078 }
00079
00080
00081 void Creature::getDescription(std::string& value, std::string& datatype) {
00082 Property::getProperty(*this, "tutorial:description", value, datatype);
00083 }
00084
00085
00086 void Creature::setImage(const std::string& data, const std::string& datatype) {
00087 Property::setProperty(*this, "tutorial:image", data, datatype);
00088 }
00089
00090
00091 void Creature::getImage(std::string& value, std::string& datatype) {
00092 Property::getProperty(*this, "tutorial:image", value, datatype);
00093 }
00094
00095
00096 void Creature::addPredator(Creature* p) {
00097
00098 vRef<Hypercard> hc = getSite()->createVobject<Hypercard>("predator", getDefaultPolicy());
00099 hc->setLink(p);
00100 insertChild(-1, "tutorial:predator", hc);
00101 }
00102
00103 void Creature::setLength(double r){
00104
00105
00106 Property::setProperty(*this, "tutorial:length", r);
00107 }
00108
00109 double Creature::getLength() {
00110 double l;
00111 Property::getProperty(*this , "tutorial:length", l);
00112 return l;
00113 }
00114
00115
00116
00117
00118
00119
00120 Animal::Animal(VobjectBase* superobject)
00121 : Creature(superobject) {
00122 }
00123
00124
00125
00126
00127
00128 const std::string Animal::getVOSType() {
00129 return "tutorial:creature.animal";
00130 }
00131
00132
00133 MetaObject* Animal::new_Animal(VobjectBase* superobject, const std::string& type) {
00134 return new Animal(superobject);
00135 }
00136
00137
00138
00139 void Animal::setTailLength(double l) {
00140 Property::setProperty(*this, "tutorial:tail-length", l);
00141 }
00142
00143 double Animal::getTailLength() {
00144
00145 try {
00146 double l;
00147 Property::getProperty(*this, "tutorial:tail-length", l);
00148 return l;
00149 } catch(NoSuchObjectError&) {
00150 return 0.0;
00151 }
00152 }
00153
00154 void Animal::addPrey(Creature* p) {
00155
00156 vRef<Hypercard> hc = getSite()->createVobject<Hypercard>("prey", getDefaultPolicy());
00157 hc->setLink(p);
00158 insertChild(-1, "tutorial:prey", hc);
00159 }
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 BEGIN_REGISTER_METAOBJECT_FACTORIES(CreaturesEtc)
00171
00172
00173
00174
00175
00176
00177
00178
00179 Site::addLocalMetaObjectFactory(typeid(Creature).name(), &Creature::new_Creature);
00180 Site::addLocalMetaObjectFactory("tutorial:creature", &Creature::new_Creature);
00181 Site::addRemoteMetaObjectFactory(typeid(Creature).name(), "tutorial:creature", &Creature::new_Creature);
00182 Site::addRemoteMetaObjectFactory("tutorial:creature", "tutorial:creature", &Creature::new_Creature);
00183
00184 Site::addLocalMetaObjectFactory(typeid(Animal).name(), &Animal::new_Animal);
00185 Site::addLocalMetaObjectFactory("tutorial:creature.animal", &Animal::new_Animal);
00186 Site::addRemoteMetaObjectFactory(typeid(Animal).name(), "tutorial:creature.animal", &Animal::new_Animal);
00187 Site::addRemoteMetaObjectFactory("tutorial:creature.animal", "tutorial:creature.animal", &Animal::new_Animal);
00188
00189 END_REGISTER_METAOBJECT_FACTORIES(CreaturesEtc)
00190