1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #include "FieldImpls.h"
25 #include "TraceManager.h"
27 #include "TableImpls.h"
31 Detail::Detail(SavableManagerPtr detail
) :
42 value_type
Detail::getID() const
44 return m_detail
->getValue(db::TableImpls::Get()->DETAILS
->DETAILID
)->getIntegerValue();
47 const std::string
& Detail::getKey() const
49 return m_detail
->getValue(db::TableImpls::Get()->DETAILS
->KEY
)->getStringValue();
52 const std::string
& Detail::getDescription() const
54 return m_detail
->getValue(db::TableImpls::Get()->DETAILS
->DESCRIPTION
)->getStringValue();
57 void Detail::setKey(const std::string
& key
)
60 ValuePtr
value(new FieldValue(db::TableImpls::Get()->DETAILS
->KEY
, key
));
61 m_detail
->setValue(value
);
64 void Detail::setDescription(const std::string
& description
)
67 ValuePtr
value(new FieldValue(db::TableImpls::Get()->DETAILS
->DESCRIPTION
, description
));
68 m_detail
->setValue(value
);
83 void mud::Detail::Delete(value_type accountid
, const std::string
& description
)
85 Assert(!"Not yet implemented.");
88 void mud::Detail::Save(value_type accountid
, const std::string
& description
)
90 if(!m_detail
->isDirty())
95 KeysPtr keys
= mud::Managers::Get()->Trace
->Add();
96 mud::TracePtr trace
= mud::Managers::Get()->Trace
->GetByKey(keys
->first()->getIntegerValue());
100 trace
->setAccount(accountid
);
102 if(description
!= Global::Get()->EmptyString
)
103 trace
->setDescription(description
);
106 trace
->setDiff(m_detail
->getDiff());
107 trace
->setTime(time(NULL
));
108 trace
->Save(); // create the Trace
110 RelationPtr
relation(new Relation(db::TableImpls::Get()->TRACEDETAIL
));
111 relation
->addKey(db::TableImpls::Get()->TRACEDETAIL
->FKDETAILS
, getID());
112 relation
->addKey(db::TableImpls::Get()->TRACEDETAIL
->FKTRACES
, keys
->first()->getIntegerValue());
113 relation
->save(); // create the relation
115 m_detail
->save(); // save the room
118 void Detail::Discard()
124 bool Detail::Exists()
126 return m_detail
->exists();
129 SavableManagerPtr
Detail::getManager() const
134 TableImplPtr
Detail::getTable() const
136 return m_detail
->getTable();