OpenMW
|
00001 #ifndef CSM_WOLRD_REFIDADAPTERIMP_H 00002 #define CSM_WOLRD_REFIDADAPTERIMP_H 00003 00004 #include <map> 00005 00006 #include <QVariant> 00007 00008 #include <components/esm/loadalch.hpp> 00009 #include <components/esm/loadappa.hpp> 00010 00011 #include "record.hpp" 00012 #include "refiddata.hpp" 00013 #include "universalid.hpp" 00014 #include "refidadapter.hpp" 00015 00016 namespace CSMWorld 00017 { 00018 struct BaseColumns 00019 { 00020 const RefIdColumn *mId; 00021 const RefIdColumn *mModified; 00022 const RefIdColumn *mType; 00023 }; 00024 00026 template<typename RecordT> 00027 class BaseRefIdAdapter : public RefIdAdapter 00028 { 00029 UniversalId::Type mType; 00030 BaseColumns mBase; 00031 00032 public: 00033 00034 BaseRefIdAdapter (UniversalId::Type type, const BaseColumns& base); 00035 00036 virtual std::string getId (const RecordBase& record) const; 00037 00038 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00039 const; 00040 00041 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00042 const QVariant& value) const; 00044 00045 UniversalId::Type getType() const; 00046 }; 00047 00048 template<typename RecordT> 00049 BaseRefIdAdapter<RecordT>::BaseRefIdAdapter (UniversalId::Type type, const BaseColumns& base) 00050 : mType (type), mBase (base) 00051 {} 00052 00053 template<typename RecordT> 00054 std::string BaseRefIdAdapter<RecordT>::getId (const RecordBase& record) const 00055 { 00056 return dynamic_cast<const Record<RecordT>&> (record).get().mId; 00057 } 00058 00059 template<typename RecordT> 00060 QVariant BaseRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, 00061 int index) const 00062 { 00063 const Record<RecordT>& record = static_cast<const Record<RecordT>&> ( 00064 data.getRecord (RefIdData::LocalIndex (index, mType))); 00065 00066 if (column==mBase.mId) 00067 return QString::fromUtf8 (record.get().mId.c_str()); 00068 00069 if (column==mBase.mModified) 00070 { 00071 if (record.mState==Record<RecordT>::State_Erased) 00072 return static_cast<int> (Record<RecordT>::State_Deleted); 00073 00074 return static_cast<int> (record.mState); 00075 } 00076 00077 if (column==mBase.mType) 00078 return static_cast<int> (mType); 00079 00080 return QVariant(); 00081 } 00082 00083 template<typename RecordT> 00084 void BaseRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index, 00085 const QVariant& value) const 00086 { 00087 Record<RecordT>& record = static_cast<Record<RecordT>&> ( 00088 data.getRecord (RefIdData::LocalIndex (index, mType))); 00089 00090 if (column==mBase.mModified) 00091 record.mState = static_cast<RecordBase::State> (value.toInt()); 00092 } 00093 00094 template<typename RecordT> 00095 UniversalId::Type BaseRefIdAdapter<RecordT>::getType() const 00096 { 00097 return mType; 00098 } 00099 00100 00101 struct ModelColumns : public BaseColumns 00102 { 00103 const RefIdColumn *mModel; 00104 00105 ModelColumns (const BaseColumns& base) : BaseColumns (base) {} 00106 }; 00107 00109 template<typename RecordT> 00110 class ModelRefIdAdapter : public BaseRefIdAdapter<RecordT> 00111 { 00112 ModelColumns mModel; 00113 00114 public: 00115 00116 ModelRefIdAdapter (UniversalId::Type type, const ModelColumns& columns); 00117 00118 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00119 const; 00120 00121 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00122 const QVariant& value) const; 00124 }; 00125 00126 template<typename RecordT> 00127 ModelRefIdAdapter<RecordT>::ModelRefIdAdapter (UniversalId::Type type, const ModelColumns& columns) 00128 : BaseRefIdAdapter<RecordT> (type, columns), mModel (columns) 00129 {} 00130 00131 template<typename RecordT> 00132 QVariant ModelRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, 00133 int index) const 00134 { 00135 const Record<RecordT>& record = static_cast<const Record<RecordT>&> ( 00136 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00137 00138 if (column==mModel.mModel) 00139 return QString::fromUtf8 (record.get().mModel.c_str()); 00140 00141 return BaseRefIdAdapter<RecordT>::getData (column, data, index); 00142 } 00143 00144 template<typename RecordT> 00145 void ModelRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index, 00146 const QVariant& value) const 00147 { 00148 Record<RecordT>& record = static_cast<Record<RecordT>&> ( 00149 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00150 00151 if (column==mModel.mModel) 00152 record.get().mModel = value.toString().toUtf8().constData(); 00153 else 00154 BaseRefIdAdapter<RecordT>::setData (column, data, index, value); 00155 } 00156 00157 struct NameColumns : public ModelColumns 00158 { 00159 const RefIdColumn *mName; 00160 const RefIdColumn *mScript; 00161 00162 NameColumns (const ModelColumns& base) : ModelColumns (base) {} 00163 }; 00164 00166 template<typename RecordT> 00167 class NameRefIdAdapter : public ModelRefIdAdapter<RecordT> 00168 { 00169 NameColumns mName; 00170 00171 public: 00172 00173 NameRefIdAdapter (UniversalId::Type type, const NameColumns& columns); 00174 00175 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00176 const; 00177 00178 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00179 const QVariant& value) const; 00181 }; 00182 00183 template<typename RecordT> 00184 NameRefIdAdapter<RecordT>::NameRefIdAdapter (UniversalId::Type type, const NameColumns& columns) 00185 : ModelRefIdAdapter<RecordT> (type, columns), mName (columns) 00186 {} 00187 00188 template<typename RecordT> 00189 QVariant NameRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, 00190 int index) const 00191 { 00192 const Record<RecordT>& record = static_cast<const Record<RecordT>&> ( 00193 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00194 00195 if (column==mName.mName) 00196 return QString::fromUtf8 (record.get().mName.c_str()); 00197 00198 if (column==mName.mScript) 00199 return QString::fromUtf8 (record.get().mScript.c_str()); 00200 00201 return ModelRefIdAdapter<RecordT>::getData (column, data, index); 00202 } 00203 00204 template<typename RecordT> 00205 void NameRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index, 00206 const QVariant& value) const 00207 { 00208 Record<RecordT>& record = static_cast<Record<RecordT>&> ( 00209 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00210 00211 if (column==mName.mName) 00212 record.get().mName = value.toString().toUtf8().constData(); 00213 else if (column==mName.mScript) 00214 record.get().mScript = value.toString().toUtf8().constData(); 00215 else 00216 ModelRefIdAdapter<RecordT>::setData (column, data, index, value); 00217 } 00218 00219 struct InventoryColumns : public NameColumns 00220 { 00221 const RefIdColumn *mIcon; 00222 const RefIdColumn *mWeight; 00223 const RefIdColumn *mValue; 00224 00225 InventoryColumns (const NameColumns& base) : NameColumns (base) {} 00226 }; 00227 00229 template<typename RecordT> 00230 class InventoryRefIdAdapter : public NameRefIdAdapter<RecordT> 00231 { 00232 InventoryColumns mInventory; 00233 00234 public: 00235 00236 InventoryRefIdAdapter (UniversalId::Type type, const InventoryColumns& columns); 00237 00238 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00239 const; 00240 00241 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00242 const QVariant& value) const; 00244 }; 00245 00246 template<typename RecordT> 00247 InventoryRefIdAdapter<RecordT>::InventoryRefIdAdapter (UniversalId::Type type, 00248 const InventoryColumns& columns) 00249 : NameRefIdAdapter<RecordT> (type, columns), mInventory (columns) 00250 {} 00251 00252 template<typename RecordT> 00253 QVariant InventoryRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, 00254 int index) const 00255 { 00256 const Record<RecordT>& record = static_cast<const Record<RecordT>&> ( 00257 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00258 00259 if (column==mInventory.mIcon) 00260 return QString::fromUtf8 (record.get().mIcon.c_str()); 00261 00262 if (column==mInventory.mWeight) 00263 return record.get().mData.mWeight; 00264 00265 if (column==mInventory.mValue) 00266 return record.get().mData.mValue; 00267 00268 return NameRefIdAdapter<RecordT>::getData (column, data, index); 00269 } 00270 00271 template<typename RecordT> 00272 void InventoryRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index, 00273 const QVariant& value) const 00274 { 00275 Record<RecordT>& record = static_cast<Record<RecordT>&> ( 00276 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00277 00278 if (column==mInventory.mIcon) 00279 record.get().mIcon = value.toString().toUtf8().constData(); 00280 else if (column==mInventory.mWeight) 00281 record.get().mData.mWeight = value.toFloat(); 00282 else if (column==mInventory.mValue) 00283 record.get().mData.mValue = value.toInt(); 00284 else 00285 NameRefIdAdapter<RecordT>::setData (column, data, index, value); 00286 } 00287 00288 class PotionRefIdAdapter : public InventoryRefIdAdapter<ESM::Potion> 00289 { 00290 const RefIdColumn *mAutoCalc; 00291 00292 public: 00293 00294 PotionRefIdAdapter (const InventoryColumns& columns, const RefIdColumn *autoCalc); 00295 00296 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00297 const; 00298 00299 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00300 const QVariant& value) const; 00302 }; 00303 00304 struct EnchantableColumns : public InventoryColumns 00305 { 00306 const RefIdColumn *mEnchantment; 00307 const RefIdColumn *mEnchantmentPoints; 00308 00309 EnchantableColumns (const InventoryColumns& base) : InventoryColumns (base) {} 00310 }; 00311 00313 template<typename RecordT> 00314 class EnchantableRefIdAdapter : public InventoryRefIdAdapter<RecordT> 00315 { 00316 EnchantableColumns mEnchantable; 00317 00318 public: 00319 00320 EnchantableRefIdAdapter (UniversalId::Type type, const EnchantableColumns& columns); 00321 00322 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00323 const; 00324 00325 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00326 const QVariant& value) const; 00328 }; 00329 00330 template<typename RecordT> 00331 EnchantableRefIdAdapter<RecordT>::EnchantableRefIdAdapter (UniversalId::Type type, 00332 const EnchantableColumns& columns) 00333 : InventoryRefIdAdapter<RecordT> (type, columns), mEnchantable (columns) 00334 {} 00335 00336 template<typename RecordT> 00337 QVariant EnchantableRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, 00338 int index) const 00339 { 00340 const Record<RecordT>& record = static_cast<const Record<RecordT>&> ( 00341 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00342 00343 if (column==mEnchantable.mEnchantment) 00344 return QString::fromUtf8 (record.get().mEnchant.c_str()); 00345 00346 if (column==mEnchantable.mEnchantmentPoints) 00347 return static_cast<int> (record.get().mData.mEnchant); 00348 00349 return InventoryRefIdAdapter<RecordT>::getData (column, data, index); 00350 } 00351 00352 template<typename RecordT> 00353 void EnchantableRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, 00354 int index, const QVariant& value) const 00355 { 00356 Record<RecordT>& record = static_cast<Record<RecordT>&> ( 00357 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00358 00359 if (column==mEnchantable.mEnchantment) 00360 record.get().mEnchant = value.toString().toUtf8().constData(); 00361 else if (column==mEnchantable.mEnchantmentPoints) 00362 record.get().mData.mEnchant = value.toInt(); 00363 else 00364 InventoryRefIdAdapter<RecordT>::setData (column, data, index, value); 00365 } 00366 00367 struct ToolColumns : public InventoryColumns 00368 { 00369 const RefIdColumn *mQuality; 00370 const RefIdColumn *mUses; 00371 00372 ToolColumns (const InventoryColumns& base) : InventoryColumns (base) {} 00373 }; 00374 00376 template<typename RecordT> 00377 class ToolRefIdAdapter : public InventoryRefIdAdapter<RecordT> 00378 { 00379 ToolColumns mTools; 00380 00381 public: 00382 00383 ToolRefIdAdapter (UniversalId::Type type, const ToolColumns& columns); 00384 00385 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00386 const; 00387 00388 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00389 const QVariant& value) const; 00391 }; 00392 00393 template<typename RecordT> 00394 ToolRefIdAdapter<RecordT>::ToolRefIdAdapter (UniversalId::Type type, const ToolColumns& columns) 00395 : InventoryRefIdAdapter<RecordT> (type, columns), mTools (columns) 00396 {} 00397 00398 template<typename RecordT> 00399 QVariant ToolRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, 00400 int index) const 00401 { 00402 const Record<RecordT>& record = static_cast<const Record<RecordT>&> ( 00403 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00404 00405 if (column==mTools.mQuality) 00406 return record.get().mData.mQuality; 00407 00408 if (column==mTools.mUses) 00409 return record.get().mData.mUses; 00410 00411 return InventoryRefIdAdapter<RecordT>::getData (column, data, index); 00412 } 00413 00414 template<typename RecordT> 00415 void ToolRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, 00416 int index, const QVariant& value) const 00417 { 00418 Record<RecordT>& record = static_cast<Record<RecordT>&> ( 00419 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00420 00421 if (column==mTools.mQuality) 00422 record.get().mData.mQuality = value.toFloat(); 00423 else if (column==mTools.mUses) 00424 record.get().mData.mUses = value.toInt(); 00425 else 00426 InventoryRefIdAdapter<RecordT>::setData (column, data, index, value); 00427 } 00428 00429 struct ActorColumns : public NameColumns 00430 { 00431 const RefIdColumn *mHasAi; 00432 const RefIdColumn *mHello; 00433 const RefIdColumn *mFlee; 00434 const RefIdColumn *mFight; 00435 const RefIdColumn *mAlarm; 00436 std::map<const RefIdColumn *, unsigned int> mServices; 00437 00438 ActorColumns (const NameColumns& base) : NameColumns (base) {} 00439 }; 00440 00442 template<typename RecordT> 00443 class ActorRefIdAdapter : public NameRefIdAdapter<RecordT> 00444 { 00445 ActorColumns mActors; 00446 00447 public: 00448 00449 ActorRefIdAdapter (UniversalId::Type type, const ActorColumns& columns); 00450 00451 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00452 const; 00453 00454 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00455 const QVariant& value) const; 00457 }; 00458 00459 template<typename RecordT> 00460 ActorRefIdAdapter<RecordT>::ActorRefIdAdapter (UniversalId::Type type, 00461 const ActorColumns& columns) 00462 : NameRefIdAdapter<RecordT> (type, columns), mActors (columns) 00463 {} 00464 00465 template<typename RecordT> 00466 QVariant ActorRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data, 00467 int index) const 00468 { 00469 const Record<RecordT>& record = static_cast<const Record<RecordT>&> ( 00470 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00471 00472 if (column==mActors.mHasAi) 00473 return record.get().mHasAI!=0; 00474 00475 if (column==mActors.mHello) 00476 return record.get().mAiData.mHello; 00477 00478 if (column==mActors.mFlee) 00479 return record.get().mAiData.mFlee; 00480 00481 if (column==mActors.mFight) 00482 return record.get().mAiData.mFight; 00483 00484 if (column==mActors.mAlarm) 00485 return record.get().mAiData.mAlarm; 00486 00487 std::map<const RefIdColumn *, unsigned int>::const_iterator iter = 00488 mActors.mServices.find (column); 00489 00490 if (iter!=mActors.mServices.end()) 00491 return (record.get().mAiData.mServices & iter->second)!=0; 00492 00493 return NameRefIdAdapter<RecordT>::getData (column, data, index); 00494 } 00495 00496 template<typename RecordT> 00497 void ActorRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index, 00498 const QVariant& value) const 00499 { 00500 Record<RecordT>& record = static_cast<Record<RecordT>&> ( 00501 data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType()))); 00502 00503 if (column==mActors.mHasAi) 00504 record.get().mHasAI = value.toInt(); 00505 else if (column==mActors.mHello) 00506 record.get().mAiData.mHello = value.toInt(); 00507 else if (column==mActors.mFlee) 00508 record.get().mAiData.mFlee = value.toInt(); 00509 else if (column==mActors.mFight) 00510 record.get().mAiData.mFight = value.toInt(); 00511 else if (column==mActors.mAlarm) 00512 record.get().mAiData.mAlarm = value.toInt(); 00513 else 00514 { 00515 typename std::map<const RefIdColumn *, unsigned int>::const_iterator iter = 00516 mActors.mServices.find (column); 00517 if (iter!=mActors.mServices.end()) 00518 { 00519 if (value.toInt()!=0) 00520 record.get().mAiData.mServices |= iter->second; 00521 else 00522 record.get().mAiData.mServices &= ~iter->second; 00523 } 00524 else 00525 NameRefIdAdapter<RecordT>::setData (column, data, index, value); 00526 } 00527 } 00528 00529 class ApparatusRefIdAdapter : public InventoryRefIdAdapter<ESM::Apparatus> 00530 { 00531 const RefIdColumn *mType; 00532 const RefIdColumn *mQuality; 00533 00534 public: 00535 00536 ApparatusRefIdAdapter (const InventoryColumns& columns, const RefIdColumn *type, 00537 const RefIdColumn *quality); 00538 00539 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00540 const; 00541 00542 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00543 const QVariant& value) const; 00545 }; 00546 00547 class ArmorRefIdAdapter : public EnchantableRefIdAdapter<ESM::Armor> 00548 { 00549 const RefIdColumn *mType; 00550 const RefIdColumn *mHealth; 00551 const RefIdColumn *mArmor; 00552 00553 public: 00554 00555 ArmorRefIdAdapter (const EnchantableColumns& columns, const RefIdColumn *type, 00556 const RefIdColumn *health, const RefIdColumn *armor); 00557 00558 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00559 const; 00560 00561 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00562 const QVariant& value) const; 00564 }; 00565 00566 class BookRefIdAdapter : public EnchantableRefIdAdapter<ESM::Book> 00567 { 00568 const RefIdColumn *mScroll; 00569 const RefIdColumn *mSkill; 00570 00571 public: 00572 00573 BookRefIdAdapter (const EnchantableColumns& columns, const RefIdColumn *scroll, 00574 const RefIdColumn *skill); 00575 00576 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00577 const; 00578 00579 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00580 const QVariant& value) const; 00582 }; 00583 00584 class ClothingRefIdAdapter : public EnchantableRefIdAdapter<ESM::Clothing> 00585 { 00586 const RefIdColumn *mType; 00587 00588 public: 00589 00590 ClothingRefIdAdapter (const EnchantableColumns& columns, const RefIdColumn *type); 00591 00592 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00593 const; 00594 00595 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00596 const QVariant& value) const; 00598 }; 00599 00600 class ContainerRefIdAdapter : public NameRefIdAdapter<ESM::Container> 00601 { 00602 const RefIdColumn *mWeight; 00603 const RefIdColumn *mOrganic; 00604 const RefIdColumn *mRespawn; 00605 00606 public: 00607 00608 ContainerRefIdAdapter (const NameColumns& columns, const RefIdColumn *weight, 00609 const RefIdColumn *organic, const RefIdColumn *respawn); 00610 00611 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00612 const; 00613 00614 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00615 const QVariant& value) const; 00617 }; 00618 00619 struct CreatureColumns : public ActorColumns 00620 { 00621 std::map<const RefIdColumn *, unsigned int> mFlags; 00622 const RefIdColumn *mType; 00623 const RefIdColumn *mSoul; 00624 const RefIdColumn *mScale; 00625 const RefIdColumn *mOriginal; 00626 00627 CreatureColumns (const ActorColumns& actorColumns); 00628 }; 00629 00630 class CreatureRefIdAdapter : public ActorRefIdAdapter<ESM::Creature> 00631 { 00632 CreatureColumns mColumns; 00633 00634 public: 00635 00636 CreatureRefIdAdapter (const CreatureColumns& columns); 00637 00638 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00639 const; 00640 00641 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00642 const QVariant& value) const; 00644 }; 00645 00646 class DoorRefIdAdapter : public NameRefIdAdapter<ESM::Door> 00647 { 00648 const RefIdColumn *mOpenSound; 00649 const RefIdColumn *mCloseSound; 00650 00651 public: 00652 00653 DoorRefIdAdapter (const NameColumns& columns, const RefIdColumn *openSound, 00654 const RefIdColumn *closeSound); 00655 00656 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00657 const; 00658 00659 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00660 const QVariant& value) const; 00662 }; 00663 00664 struct LightColumns : public InventoryColumns 00665 { 00666 const RefIdColumn *mTime; 00667 const RefIdColumn *mRadius; 00668 const RefIdColumn *mColor; 00669 const RefIdColumn *mSound; 00670 std::map<const RefIdColumn *, unsigned int> mFlags; 00671 00672 LightColumns (const InventoryColumns& columns); 00673 }; 00674 00675 class LightRefIdAdapter : public InventoryRefIdAdapter<ESM::Light> 00676 { 00677 LightColumns mColumns; 00678 00679 public: 00680 00681 LightRefIdAdapter (const LightColumns& columns); 00682 00683 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00684 const; 00685 00686 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00687 const QVariant& value) const; 00689 }; 00690 00691 class MiscRefIdAdapter : public InventoryRefIdAdapter<ESM::Miscellaneous> 00692 { 00693 const RefIdColumn *mKey; 00694 00695 public: 00696 00697 MiscRefIdAdapter (const InventoryColumns& columns, const RefIdColumn *key); 00698 00699 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00700 const; 00701 00702 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00703 const QVariant& value) const; 00705 }; 00706 00707 struct NpcColumns : public ActorColumns 00708 { 00709 std::map<const RefIdColumn *, unsigned int> mFlags; 00710 const RefIdColumn *mRace; 00711 const RefIdColumn *mClass; 00712 const RefIdColumn *mFaction; 00713 const RefIdColumn *mHair; 00714 const RefIdColumn *mHead; 00715 00716 NpcColumns (const ActorColumns& actorColumns); 00717 }; 00718 00719 class NpcRefIdAdapter : public ActorRefIdAdapter<ESM::NPC> 00720 { 00721 NpcColumns mColumns; 00722 00723 public: 00724 00725 NpcRefIdAdapter (const NpcColumns& columns); 00726 00727 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00728 const; 00729 00730 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00731 const QVariant& value) const; 00733 }; 00734 00735 struct WeaponColumns : public EnchantableColumns 00736 { 00737 const RefIdColumn *mType; 00738 const RefIdColumn *mHealth; 00739 const RefIdColumn *mSpeed; 00740 const RefIdColumn *mReach; 00741 const RefIdColumn *mChop[2]; 00742 const RefIdColumn *mSlash[2]; 00743 const RefIdColumn *mThrust[2]; 00744 std::map<const RefIdColumn *, unsigned int> mFlags; 00745 00746 WeaponColumns (const EnchantableColumns& columns); 00747 }; 00748 00749 class WeaponRefIdAdapter : public EnchantableRefIdAdapter<ESM::Weapon> 00750 { 00751 WeaponColumns mColumns; 00752 00753 public: 00754 00755 WeaponRefIdAdapter (const WeaponColumns& columns); 00756 00757 virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) 00758 const; 00759 00760 virtual void setData (const RefIdColumn *column, RefIdData& data, int index, 00761 const QVariant& value) const; 00763 }; 00764 } 00765 00766 #endif