Like SgPropTime, but gets stored with millisecond precision rather than tenths of a second. More...
#include <SgProp.h>
Public Member Functions | |
SgPropMSec (SgPropID id) | |
SgPropMSec (SgPropID id, double value) | |
virtual | ~SgPropMSec () |
SgProp * | Duplicate () const |
Override this function for each property class to return an exact duplicate of this property. | |
bool | ToString (std::vector< std::string > &values, int boardSize, SgPropPointFmt fmt, int fileFormat) const |
Convert the property into string representation. | |
bool | FromString (const std::vector< std::string > &values, int boardSize, SgPropPointFmt fmt) |
Override this method to convert the string read from disk to the value of this property, and set the value of this property. | |
double | Value () const |
void | SetValue (double value, int precision=0) |
SgPropID | ID () const |
Return the property type of this property. | |
virtual SgPropFlags | Flags () const |
Get the flags for this property type. | |
virtual std::string | Label () const |
Get the the label for this property type. | |
bool | Flag (SgPropFlags flags) const |
Return whether any of the given flags are set for this property. | |
SgBlackWhite | Player () const |
If this property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return that property. | |
bool | IsPlayer (SgBlackWhite player) const |
virtual void | ChangeToOpponent () |
Override this method to do something special when changing the color of a property (e.g. | |
bool | MatchesID (SgPropID id) const |
Return true if the given 'id' matches this property. | |
virtual bool | ContainsText (const std::string &findText) |
Return true if this property matches the given text. | |
Static Public Member Functions | |
static SgPropID | Register (SgProp *prop, const char *label, SgPropFlags flags=0) |
Call this function with a property of the right type to register that property type. | |
static SgProp * | CreateProperty (SgPropID id) |
Create a property with the given property ID. | |
static SgPropID | GetIDOfLabel (const std::string &label) |
Return the ID for a given label. | |
static SgPropID | ConvertFindTextToPropID (const std::string &findText) |
Convert the text specified in the Find dialog to special propIDs to search for. | |
static void | Init () |
Initialize properties. | |
static void | Fini () |
Finalize properties. | |
static SgPropID | OpponentProp (SgPropID id) |
If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of the opposite color, otherwise return 'id'. | |
static SgPropID | PlayerProp (SgPropID id, SgBlackWhite player) |
If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of player's color, otherwise return 'id'. | |
Static Protected Member Functions | |
static bool | Initialized () |
Protected Attributes | |
int | m_precision |
double | m_value |
SgPropID | m_id |
Like SgPropTime, but gets stored with millisecond precision rather than tenths of a second.
Definition at line 656 of file SgProp.h.
SgPropMSec::SgPropMSec | ( | SgPropID | id | ) | [explicit] |
Definition at line 669 of file SgProp.h.
Referenced by Duplicate().
SgPropMSec::~SgPropMSec | ( | ) | [virtual] |
Definition at line 967 of file SgProp.cpp.
void SgProp::ChangeToOpponent | ( | ) | [virtual, inherited] |
Override this method to do something special when changing the color of a property (e.g.
a value might need to be negated).
Reimplemented in SgPropValue, and SgPropPlayer.
Definition at line 390 of file SgProp.cpp.
References SgProp::m_id, and SgProp::OpponentProp().
bool SgProp::ContainsText | ( | const std::string & | findText | ) | [virtual, inherited] |
Return true if this property matches the given text.
Override for specific properties.
Reimplemented in SgPropText, and SgPropTextList.
Definition at line 395 of file SgProp.cpp.
References SG_UNUSED().
Referenced by SgPropList::GetPropContainingText().
SgPropID SgProp::ConvertFindTextToPropID | ( | const std::string & | findText | ) | [static, inherited] |
Convert the text specified in the Find dialog to special propIDs to search for.
Return SG_PROP_NONE if the literal text should be searched for.
Definition at line 525 of file SgProp.cpp.
References SG_PROP_ANNOTATE, SG_PROP_BAD_MOVE, SG_PROP_BRANCH, SG_PROP_CHECK, SG_PROP_COMMENT, SG_PROP_GOOD_MOVE, SG_PROP_HOTSPOT, SG_PROP_INFO, SG_PROP_MARKS, SG_PROP_MOVE_BLACK, SG_PROP_MOVE_WHITE, SG_PROP_NAME, SG_PROP_NONE, SG_PROP_SIGMA, SG_PROP_TERMINAL, and SG_PROP_TRIANGLE.
Referenced by SgNode::ContainsText().
Create a property with the given property ID.
Definition at line 439 of file SgProp.cpp.
References SgProp::Duplicate(), SgProp::m_id, SgProp::s_numPropClasses, SgProp::s_prop, and SG_ASSERT.
Referenced by SgGameReader::HandleProperties(), SgNode::SetIntProp(), SgNode::SetListProp(), SgNode::SetRealProp(), and SgNode::SetStringProp().
SgProp * SgPropMSec::Duplicate | ( | ) | const [virtual] |
Override this function for each property class to return an exact duplicate of this property.
Reimplemented from SgPropTime.
Definition at line 971 of file SgProp.cpp.
References SgProp::m_id, SgPropReal::m_value, and SgPropMSec().
void SgProp::Fini | ( | ) | [static, inherited] |
Finalize properties.
Definition at line 805 of file SgProp.cpp.
References SgProp::s_initialized.
Referenced by SgFini().
bool SgProp::Flag | ( | SgPropFlags | flags | ) | const [inherited] |
Return whether any of the given flags are set for this property.
Definition at line 384 of file SgProp.h.
References SgProp::Flags().
Referenced by SgPropList::Add(), SgNode::Add(), SgProp::Player(), SgGameWriter::ShouldWriteProperty(), and SgGameWriter::WriteNode().
SgPropFlags SgProp::Flags | ( | ) | const [virtual, inherited] |
Get the flags for this property type.
Not normally overridden.
Definition at line 401 of file SgProp.cpp.
References SgProp::m_id, and SgProp::s_flags.
Referenced by SgProp::Flag(), SgProp::MatchesID(), and SgProp::Player().
bool SgPropReal::FromString | ( | const std::vector< std::string > & | values, | |
int | boardSize, | |||
SgPropPointFmt | fmt | |||
) | [virtual, inherited] |
Override this method to convert the string read from disk to the value of this property, and set the value of this property.
Implements SgProp.
Definition at line 927 of file SgProp.cpp.
References SgPropReal::m_value, and SG_UNUSED().
SgPropID SgProp::GetIDOfLabel | ( | const std::string & | label | ) | [static, inherited] |
Return the ID for a given label.
Return SG_PROP_NONE if there is no property with that label.
Definition at line 451 of file SgProp.cpp.
References SgProp::s_label, SgProp::s_numPropClasses, and SG_PROP_NONE.
Referenced by SgGameReader::HandleProperties().
SgPropID SgProp::ID | ( | ) | const [inherited] |
Return the property type of this property.
Definition at line 379 of file SgProp.h.
References SgProp::m_id.
Referenced by SgPropList::Add(), SgPropList::AppendMoveAnnotation(), SgPropPointList::Duplicate(), SgProp::MatchesID(), and SgGameWriter::ShouldWriteProperty().
void SgProp::Init | ( | ) | [static, inherited] |
Initialize properties.
Registers most properties. Does not register SG_PROP_MOVE_BLACK ("B") and SG_PROP_MOVE_WHITE ("W"), because they are game dependent.
Definition at line 556 of file SgProp.cpp.
References SgProp::Register(), SgProp::s_flags, SgProp::s_initialized, SgProp::s_label, SgProp::s_prop, SG_PROP_ADD_BLACK, SG_PROP_ADD_EMPTY, SG_PROP_ADD_WHITE, SG_PROP_ANALYSIS, SG_PROP_ANNOTATE, SG_PROP_APPLIC, SG_PROP_BAD_MOVE, SG_PROP_BRANCH, SG_PROP_CHECK, SG_PROP_CHINESE, SG_PROP_CIRCLE, SG_PROP_COMMENT, SG_PROP_COPYRIGHT, SG_PROP_COUNT, SG_PROP_DATE, SG_PROP_DEPTH, SG_PROP_DIAMOND, SG_PROP_DIMMED, SG_PROP_DOUBTFUL, SG_PROP_EVAL, SG_PROP_EVEN_POS, SG_PROP_EVENT, SG_PROP_EXPECTED, SG_PROP_FIGURE, SG_PROP_FIND_MOVE, SG_PROP_FIND_TEXT, SG_PROP_FORMAT, SG_PROP_GAME, SG_PROP_GAME_COMMENT, SG_PROP_GAME_NAME, SG_PROP_GOOD_BLACK, SG_PROP_GOOD_MOVE, SG_PROP_GOOD_WHITE, SG_PROP_HANDICAP, SG_PROP_HOTSPOT, SG_PROP_INFO, SG_PROP_INTERESTING, SG_PROP_KOMI, SG_PROP_LABEL, SG_PROP_LOSE_TIME, SG_PROP_MARKED, SG_PROP_MARKS, SG_PROP_MAX_DEPTH, SG_PROP_MOTIVE, SG_PROP_MOVE, SG_PROP_MOVE_ANNO, SG_PROP_NAME, SG_PROP_NONE, SG_PROP_NOT_BLACK, SG_PROP_NOT_EMPTY, SG_PROP_NOT_WHITE, SG_PROP_NUM_LEAFS, SG_PROP_NUM_NODES, SG_PROP_OPENING, SG_PROP_OT_BLACK, SG_PROP_OT_NU_MOVES, SG_PROP_OT_PERIOD, SG_PROP_OT_WHITE, SG_PROP_OVERHEAD, SG_PROP_PART_DEPTH, SG_PROP_PLACE, SG_PROP_PLAYER, SG_PROP_PLAYER_BLACK, SG_PROP_PLAYER_WHITE, SG_PROP_POS_ANNO, SG_PROP_RANK_BLACK, SG_PROP_RANK_WHITE, SG_PROP_RESULT, SG_PROP_ROUND, SG_PROP_RULES, SG_PROP_SELECT, SG_PROP_SEQUENCE, SG_PROP_SIGMA, SG_PROP_SIZE, SG_PROP_SOURCE, SG_PROP_SPEC_BLACK, SG_PROP_SPEC_WHITE, SG_PROP_SQUARE, SG_PROP_TEAM_BLACK, SG_PROP_TEAM_WHITE, SG_PROP_TERMINAL, SG_PROP_TERR_BLACK, SG_PROP_TERR_WHITE, SG_PROP_TIME, SG_PROP_TIME_BLACK, SG_PROP_TIME_USED, SG_PROP_TIME_WHITE, SG_PROP_TIMES, SG_PROP_TRIANGLE, SG_PROP_UNCLEAR, SG_PROP_UNKNOWN, SG_PROP_USER, SG_PROP_VALUE, SG_PROPCLASS_ABSTRACT, SG_PROPCLASS_ANNO, SG_PROPCLASS_ANNO_MOVE, SG_PROPCLASS_ANNO_POS, SG_PROPCLASS_BLACK, SG_PROPCLASS_CUSTOM, SG_PROPCLASS_INFO, SG_PROPCLASS_MARK, SG_PROPCLASS_MOVE, SG_PROPCLASS_NEWLINE, SG_PROPCLASS_NOT_FF3, SG_PROPCLASS_NOTCLEAN, SG_PROPCLASS_ROOT, SG_PROPCLASS_STAT, SG_PROPCLASS_TIME, and SG_PROPCLASS_WHITE.
Referenced by SgInitImpl().
bool SgProp::Initialized | ( | ) | [static, protected, inherited] |
Definition at line 406 of file SgProp.cpp.
References SgProp::s_initialized.
Referenced by SgPropInt::Value().
bool SgProp::IsPlayer | ( | SgBlackWhite | player | ) | const [inherited] |
Definition at line 502 of file SgProp.cpp.
References SgProp::Player(), and SG_ASSERT_BW.
string SgProp::Label | ( | ) | const [virtual, inherited] |
Get the the label for this property type.
Overridden only by SgPropUnknown.
Reimplemented in SgPropUnknown.
Definition at line 411 of file SgProp.cpp.
References SgProp::m_id, and SgProp::s_label.
Referenced by SgGameWriter::ShouldWriteProperty(), and SgGameWriter::WriteNode().
bool SgProp::MatchesID | ( | SgPropID | id | ) | const [inherited] |
Return true if the given 'id' matches this property.
The special properties SG_PROP_INFO, SG_PROP_ANNOTATE, SG_PROP_POS_ANNO, SG_PROP_MOVE_ANNO, and SG_PROP_COUNT match any property that has the corresponding flag set.
Definition at line 508 of file SgProp.cpp.
References SgProp::Flags(), SgProp::ID(), SgProp::s_flags, and SG_PROPCLASS_ABSTRACT.
Referenced by SgPropList::Get(), and SgPropList::Remove().
If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of the opposite color, otherwise return 'id'.
Definition at line 459 of file SgProp.cpp.
References SgProp::s_flags, SG_ASSERT, SG_PROPCLASS_BLACK, and SG_PROPCLASS_WHITE.
Referenced by SgProp::ChangeToOpponent(), and SgProp::PlayerProp().
SgBlackWhite SgProp::Player | ( | ) | const [inherited] |
If this property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return that property.
Otherwise the return value is undefined (checked with assertion).
Definition at line 491 of file SgProp.cpp.
References SgProp::Flag(), SgProp::Flags(), SG_ASSERT, SG_BLACK, SG_PROPCLASS_BLACK, SG_PROPCLASS_WHITE, and SG_WHITE.
Referenced by SgProp::IsPlayer().
SgPropID SgProp::PlayerProp | ( | SgPropID | id, | |
SgBlackWhite | player | |||
) | [static, inherited] |
If the given property is marked as either SG_PROPCLASS_BLACK or SG_PROPCLASS_WHITE, return the property of player's color, otherwise return 'id'.
Definition at line 479 of file SgProp.cpp.
References SgProp::OpponentProp(), SgProp::s_flags, SG_ASSERT, SG_PROPCLASS_BLACK, SG_PROPCLASS_WHITE, and SG_WHITE.
Referenced by SgTimeRecord::PlayedMove(), and SgTimeRecord::SetClock().
SgPropID SgProp::Register | ( | SgProp * | prop, | |
const char * | label, | |||
SgPropFlags | flags = 0 | |||
) | [static, inherited] |
Call this function with a property of the right type to register that property type.
Ownership of 'prop' is passed to the Property class; it will dispose the property upon exit. Register returns the property identifier to be used to refer to this property. Abstract properties can be registered with 'prop' set to 0. No property object of that type can be instantiated. (?? useful for searching?) This method asserts and returns 0 if the registry is full.
Definition at line 416 of file SgProp.cpp.
References SgProp::m_id, SgProp::s_flags, SgProp::s_label, SgProp::s_numPropClasses, SgProp::s_prop, SG_ASSERT, SG_MAX_PROPCLASS, SG_PROPCLASS_BLACK, and SG_PROPCLASS_WHITE.
Referenced by SgProp::Init().
void SgPropReal::SetValue | ( | double | value, | |
int | precision = 0 | |||
) | [inherited] |
Definition at line 551 of file SgProp.h.
References SgPropReal::m_precision, and SgPropReal::m_value.
Referenced by SgNode::SetRealProp().
bool SgPropReal::ToString | ( | std::vector< std::string > & | values, | |
int | boardSize, | |||
SgPropPointFmt | fmt, | |||
int | fileFormat | |||
) | const [virtual, inherited] |
Convert the property into string representation.
Escapes special characters if needed (this depends on the property, e.g. the colon needs to be escaped only by some properties) Use the default file format if 'fileFormat' is zero; use the proper version of the sgf file format if 'fileFormat' is 3 or greater.
Implements SgProp.
Definition at line 913 of file SgProp.cpp.
References SgPropReal::m_precision, SgPropReal::m_value, and SG_UNUSED().
double SgPropReal::Value | ( | ) | const [inherited] |
Definition at line 546 of file SgProp.h.
References SgPropReal::m_value.
Referenced by SgNode::GetRealProp().
SgPropID SgProp::m_id [protected, inherited] |
Definition at line 351 of file SgProp.h.
Referenced by SgProp::ChangeToOpponent(), SgProp::CreateProperty(), SgPropMove::Duplicate(), SgPropAddStone::Duplicate(), SgPropPlayer::Duplicate(), SgPropTextList::Duplicate(), SgPropText::Duplicate(), Duplicate(), SgPropTime::Duplicate(), SgPropValue::Duplicate(), SgPropReal::Duplicate(), SgPropInt::Duplicate(), SgPropMultiple::Duplicate(), SgPropSimple::Duplicate(), SgPropUnknown::Duplicate(), SgProp::Flags(), SgProp::ID(), SgProp::Label(), and SgProp::Register().
int SgPropReal::m_precision [protected, inherited] |
Definition at line 527 of file SgProp.h.
Referenced by SgPropTime::Duplicate(), SgPropReal::Duplicate(), SgPropReal::SetValue(), and SgPropReal::ToString().
double SgPropReal::m_value [protected, inherited] |
Definition at line 529 of file SgProp.h.
Referenced by Duplicate(), SgPropTime::Duplicate(), SgPropReal::Duplicate(), SgPropReal::FromString(), SgPropReal::SetValue(), SgPropReal::ToString(), and SgPropReal::Value().