Structural deformable models
Public Types | Public Member Functions | Public Attributes | List of all members
Winner Class Reference

#include <ExpMap.h>

Collaboration diagram for Winner:
Collaboration graph
[legend]

Public Types

enum  ReservedID {
  WID_EMPTY = 0, WID_FIRST, WID_LAST = 0xfffffdff, WID_FRAME,
  WID_BLOCKED, WID_FIRSTFREE
}
 
typedef std::map< std::string, dwordBestRatings
 
typedef const std::map< std::string, dwordCBestRatings
 
typedef std::map< std::string, std::map< dword, float > > Ratings
 
typedef const std::map< std::string, std::map< dword, float > > CRatings
 

Public Member Functions

 Winner (Model *m=NULL)
 
void setModel (Model *m)
 
void setStructName (const std::string &sname)
 
void clearRatings ()
 
float rateBy (const std::string &creatorname, dword creatorid, float rating)
 
float updateBestRating ()
 
const BestRatings::mapped_type & getBestRatingID (const std::string &sname) const
 
const Ratings::mapped_type & getRatingList (const std::string &sname) const
 
const std::pair< dword, float > getBest (const std::string &sname) const
 
bool hasConnection (const std::string &sname) const
 
float getConnection (const std::string &sname, dword wid) const
 

Public Attributes

Modelm_Model
 
dword m_WinnerID
 
std::string m_StructName
 
float m_BestRating
 
Ratings m_Ratings
 
BestRatings m_BestRatings
 

Detailed Description

Definition at line 10 of file ExpMap.h.

Member Typedef Documentation

typedef std::map<std::string,dword> Winner::BestRatings

Definition at line 14 of file ExpMap.h.

typedef const std::map<std::string,dword> Winner::CBestRatings

Definition at line 15 of file ExpMap.h.

typedef const std::map<std::string, std::map<dword,float> > Winner::CRatings

Definition at line 17 of file ExpMap.h.

typedef std::map<std::string, std::map<dword,float> > Winner::Ratings

Definition at line 16 of file ExpMap.h.

Member Enumeration Documentation

Enumerator
WID_EMPTY 
WID_FIRST 
WID_LAST 
WID_FRAME 
WID_BLOCKED 
WID_FIRSTFREE 

Definition at line 12 of file ExpMap.h.

Constructor & Destructor Documentation

Winner::Winner ( Model m = NULL)
inline

Definition at line 19 of file ExpMap.h.

References setModel().

20  { setModel(m); }
void setModel(Model *m)
Definition: ExpMap.cpp:281
float m_BestRating
Definition: ExpMap.h:39
dword m_WinnerID
Definition: ExpMap.h:37

Member Function Documentation

void Winner::clearRatings ( )

Definition at line 288 of file ExpMap.cpp.

Referenced by ExpectationMap::ratePropVec(), and setStructName().

289 {
290  m_BestRating = 0.0f;
291  m_BestRatings.clear();
292  m_Ratings.clear();
293 }
BestRatings m_BestRatings
Definition: ExpMap.h:41
float m_BestRating
Definition: ExpMap.h:39
Ratings m_Ratings
Definition: ExpMap.h:40
const std::pair< dword, float > Winner::getBest ( const std::string &  sname) const

Definition at line 306 of file ExpMap.cpp.

Referenced by getRatingList().

307 {
308  const std::map<dword,float>& rl = getRatingList(sname);
309  dword bid = getBestRatingID(sname);
310  return *rl.find(bid);
311 }
const Ratings::mapped_type & getRatingList(const std::string &sname) const
Definition: ExpMap.h:29
unsigned long dword
Definition: simpletypes.h:6
const BestRatings::mapped_type & getBestRatingID(const std::string &sname) const
Definition: ExpMap.h:27
const BestRatings::mapped_type& Winner::getBestRatingID ( const std::string &  sname) const
inline

Definition at line 27 of file ExpMap.h.

References m_BestRatings.

28  { return m_BestRatings.find(sname)->second; }
BestRatings m_BestRatings
Definition: ExpMap.h:41
float Winner::getConnection ( const std::string &  sname,
dword  wid 
) const

Definition at line 313 of file ExpMap.cpp.

Referenced by hasConnection(), and StructPath::print().

314 {
315  if(!hasConnection(sname)) return -1.f;
316  const std::map<dword,float>& rl = getRatingList(sname);
317  std::map<dword,float>::const_iterator rt = rl.find(wid);
318  if(rt != rl.end()) return rt->second;
319  else return -1.f;
320 }
const Ratings::mapped_type & getRatingList(const std::string &sname) const
Definition: ExpMap.h:29
bool hasConnection(const std::string &sname) const
Definition: ExpMap.h:32
const Ratings::mapped_type& Winner::getRatingList ( const std::string &  sname) const
inline

Definition at line 29 of file ExpMap.h.

References getBest(), and m_Ratings.

30  { return m_Ratings.find(sname)->second; }
Ratings m_Ratings
Definition: ExpMap.h:40
bool Winner::hasConnection ( const std::string &  sname) const
inline

Definition at line 32 of file ExpMap.h.

References getConnection(), and m_Ratings.

33  { return m_Ratings.find(sname) != m_Ratings.end(); }
Ratings m_Ratings
Definition: ExpMap.h:40
float Winner::rateBy ( const std::string &  creatorname,
dword  creatorid,
float  rating 
)

Definition at line 295 of file ExpMap.cpp.

Referenced by ExpectationMap::ratePropVec(), and setStructName().

296 {
297  m_Ratings[creatorname][creatorid] = rating;
298  dword& brid = m_BestRatings[creatorname];
299  if(!brid || m_Ratings[creatorname][brid] < rating) {
300  brid = creatorid;
301  if(m_BestRating < rating) m_BestRating = rating;
302  }
303  return m_BestRating;
304 }
BestRatings m_BestRatings
Definition: ExpMap.h:41
float m_BestRating
Definition: ExpMap.h:39
unsigned long dword
Definition: simpletypes.h:6
Ratings m_Ratings
Definition: ExpMap.h:40
void Winner::setModel ( Model m)

Definition at line 281 of file ExpMap.cpp.

References Model::getID(), Model::getName(), and WID_EMPTY.

Referenced by Winner().

282 {
283  m_Model = m;
284  m_WinnerID = m ? m->getID() : Winner::WID_EMPTY;
285  m_StructName = m ? m->getName() : "";
286 }
std::string m_StructName
Definition: ExpMap.h:38
Model * m_Model
Definition: ExpMap.h:36
dword getID() const
Definition: Model.h:83
dword m_WinnerID
Definition: ExpMap.h:37
const std::string & getName() const
Definition: Model.h:81
void Winner::setStructName ( const std::string &  sname)
inline

Definition at line 22 of file ExpMap.h.

References clearRatings(), m_StructName, rateBy(), and updateBestRating().

22 { m_StructName = sname; }
std::string m_StructName
Definition: ExpMap.h:38
float Winner::updateBestRating ( )

Definition at line 322 of file ExpMap.cpp.

Referenced by setStructName().

323 {
324  m_BestRating = 0.f;
325  m_BestRatings.clear();
326  for(Ratings::const_iterator refstruct = m_Ratings.begin();
327  refstruct != m_Ratings.end(); refstruct++)
328  {
329  dword& brid = m_BestRatings[refstruct->first];
330  float bestrating = 0.f; //m_Ratings[refstruct->first][brid];
331  for(std::map<dword,float>::const_iterator wr= refstruct->second.begin();
332  wr != refstruct->second.end(); wr++)
333  { // for each rating wr
334  if(wr->second > bestrating) {
335  bestrating = wr->second;
336  brid = wr->first;
337  }
338  }
339  if(m_BestRating < bestrating) m_BestRating = bestrating;
340  }
341  return m_BestRating;
342 }
BestRatings m_BestRatings
Definition: ExpMap.h:41
float m_BestRating
Definition: ExpMap.h:39
unsigned long dword
Definition: simpletypes.h:6
Ratings m_Ratings
Definition: ExpMap.h:40

Member Data Documentation

float Winner::m_BestRating
BestRatings Winner::m_BestRatings

Definition at line 41 of file ExpMap.h.

Referenced by getBestRatingID().

Model* Winner::m_Model
Ratings Winner::m_Ratings

Definition at line 40 of file ExpMap.h.

Referenced by StructTable::findBestConnection(), getRatingList(), and hasConnection().

std::string Winner::m_StructName
dword Winner::m_WinnerID

The documentation for this class was generated from the following files: