#include <SgProp.h>
Inheritance diagram for SgProp:
Definition at line 257 of file SgProp.h.
Public Member Functions | |
SgProp (SgPropID id) | |
virtual | ~SgProp () |
virtual SgProp * | Duplicate () const =0 |
Override this function for each property class to return an exact duplicate of this property. | |
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. | |
virtual bool | ToString (std::vector< std::string > &values, int boardSize, SgPropPointFmt fmt, int fileFormat) const =0 |
Convert the property into string representation. | |
virtual bool | FromString (const std::vector< std::string > &values, int boardSize, SgPropPointFmt fmt)=0 |
Override this method to convert the string read from disk to the value of this property, and set the value of 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 | |
SgPropID | m_id |
Private Member Functions | |
SgProp (const SgProp &) | |
not implemented | |
SgProp & | operator= (const SgProp &) |
not implemented | |
Static Private Attributes | |
static bool | s_initialized = false |
Was SgProp::Init() called? | |
static int | s_numPropClasses = 0 |
static SgPropFlags | s_flags [SG_MAX_PROPCLASS] |
static std::string | s_label [SG_MAX_PROPCLASS] |
static SgProp * | s_prop [SG_MAX_PROPCLASS] |
SgProp::~SgProp | ( | ) | [virtual] |
Definition at line 387 of file SgProp.cpp.
SgProp::SgProp | ( | const SgProp & | ) | [private] |
not implemented
void SgProp::ChangeToOpponent | ( | ) | [virtual] |
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 391 of file SgProp.cpp.
References m_id, and OpponentProp().
bool SgProp::ContainsText | ( | const std::string & | findText | ) | [virtual] |
Return true if this property matches the given text.
Override for specific properties.
Reimplemented in SgPropText, and SgPropTextList.
Definition at line 396 of file SgProp.cpp.
References SG_UNUSED().
SgPropID SgProp::ConvertFindTextToPropID | ( | const std::string & | findText | ) | [static] |
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 526 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 440 of file SgProp.cpp.
References Duplicate(), m_id, s_numPropClasses, s_prop, and SG_ASSERT.
Referenced by SgGameReader::HandleProperties(), SgNode::SetIntProp(), SgNode::SetListProp(), SgNode::SetRealProp(), and SgNode::SetStringProp().
virtual SgProp* SgProp::Duplicate | ( | ) | const [pure virtual] |
Override this function for each property class to return an exact duplicate of this property.
Implemented in SgPropUnknown, SgPropInt, SgPropReal, SgPropSimple, SgPropMultiple, SgPropValue, SgPropTime, SgPropMSec, SgPropMove, SgPropPointList, SgPropText, SgPropTextList, SgPropPlayer, and SgPropAddStone.
Referenced by SgNode::CopyPropFrom(), and CreateProperty().
void SgProp::Fini | ( | ) | [static] |
Finalize properties.
Definition at line 806 of file SgProp.cpp.
References s_initialized.
Referenced by SgFini().
bool SgProp::Flag | ( | SgPropFlags | flags | ) | const |
Return whether any of the given flags are set for this property.
Definition at line 411 of file SgProp.h.
References Flags().
Referenced by SgPropList::Add(), SgNode::Add(), Player(), and SgGameWriter::ShouldWriteProperty().
SgPropFlags SgProp::Flags | ( | ) | const [virtual] |
Get the flags for this property type.
Not normally overridden.
Definition at line 402 of file SgProp.cpp.
Referenced by Flag(), MatchesID(), and Player().
virtual bool SgProp::FromString | ( | const std::vector< std::string > & | values, | |
int | boardSize, | |||
SgPropPointFmt | fmt | |||
) | [pure virtual] |
Override this method to convert the string read from disk to the value of this property, and set the value of this property.
Implemented in SgPropUnknown, SgPropInt, SgPropReal, SgPropSimple, SgPropMove, SgPropPointList, SgPropText, SgPropTextList, and SgPropPlayer.
Referenced by SgGameReader::HandleProperties().
SgPropID SgProp::GetIDOfLabel | ( | const std::string & | label | ) | [static] |
Return the ID for a given label.
Return SG_PROP_NONE if there is no property with that label.
Definition at line 452 of file SgProp.cpp.
References s_label, s_numPropClasses, and SG_PROP_NONE.
Referenced by SgGameReader::HandleProperties().
SgPropID SgProp::ID | ( | ) | const |
Return the property type of this property.
Definition at line 406 of file SgProp.h.
References m_id.
Referenced by SgPropList::Add(), SgPropList::AppendMoveAnnotation(), SgPropPointList::Duplicate(), MatchesID(), and SgGameWriter::ShouldWriteProperty().
void SgProp::Init | ( | ) | [static] |
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 557 of file SgProp.cpp.
References Register(), s_flags, s_initialized, s_label, 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] |
Definition at line 407 of file SgProp.cpp.
References s_initialized.
Referenced by SgPropInt::Value().
bool SgProp::IsPlayer | ( | SgBlackWhite | player | ) | const |
string SgProp::Label | ( | ) | const [virtual] |
Get the the label for this property type.
Overridden only by SgPropUnknown.
Reimplemented in SgPropUnknown.
Definition at line 412 of file SgProp.cpp.
Referenced by SgGameWriter::ShouldWriteProperty().
bool SgProp::MatchesID | ( | SgPropID | id | ) | const |
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 509 of file SgProp.cpp.
References Flags(), ID(), s_flags, and SG_PROPCLASS_ABSTRACT.
Referenced by 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 460 of file SgProp.cpp.
References s_flags, SG_ASSERT, SG_PROPCLASS_BLACK, and SG_PROPCLASS_WHITE.
Referenced by ChangeToOpponent(), and PlayerProp().
SgBlackWhite SgProp::Player | ( | ) | const |
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 492 of file SgProp.cpp.
References Flag(), Flags(), SG_ASSERT, SG_BLACK, SG_PROPCLASS_BLACK, SG_PROPCLASS_WHITE, and SG_WHITE.
Referenced by IsPlayer().
SgPropID SgProp::PlayerProp | ( | SgPropID | id, | |
SgBlackWhite | player | |||
) | [static] |
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 480 of file SgProp.cpp.
References OpponentProp(), 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] |
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 417 of file SgProp.cpp.
References m_id, s_flags, s_label, s_numPropClasses, s_prop, SG_ASSERT, SG_MAX_PROPCLASS, SG_PROPCLASS_BLACK, and SG_PROPCLASS_WHITE.
Referenced by Init().
virtual bool SgProp::ToString | ( | std::vector< std::string > & | values, | |
int | boardSize, | |||
SgPropPointFmt | fmt, | |||
int | fileFormat | |||
) | const [pure virtual] |
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.
Implemented in SgPropUnknown, SgPropInt, SgPropReal, SgPropSimple, SgPropMove, SgPropPointList, SgPropText, SgPropTextList, and SgPropPlayer.
SgPropID SgProp::m_id [protected] |
Definition at line 378 of file SgProp.h.
Referenced by ChangeToOpponent(), CreateProperty(), SgPropMove::Duplicate(), SgPropAddStone::Duplicate(), SgPropPlayer::Duplicate(), SgPropTextList::Duplicate(), SgPropText::Duplicate(), SgPropMSec::Duplicate(), SgPropTime::Duplicate(), SgPropValue::Duplicate(), SgPropReal::Duplicate(), SgPropInt::Duplicate(), SgPropMultiple::Duplicate(), SgPropSimple::Duplicate(), SgPropUnknown::Duplicate(), Flags(), ID(), Label(), and Register().
SgPropFlags SgProp::s_flags [static, private] |
Definition at line 388 of file SgProp.h.
Referenced by Flags(), Init(), MatchesID(), OpponentProp(), PlayerProp(), and Register().
bool SgProp::s_initialized = false [static, private] |
Was SgProp::Init() called?
Definition at line 384 of file SgProp.h.
Referenced by Fini(), Init(), and Initialized().
string SgProp::s_label [static, private] |
Definition at line 390 of file SgProp.h.
Referenced by GetIDOfLabel(), Init(), Label(), and Register().
int SgProp::s_numPropClasses = 0 [static, private] |
Definition at line 386 of file SgProp.h.
Referenced by CreateProperty(), GetIDOfLabel(), and Register().
SgProp * SgProp::s_prop [static, private] |