22 #include <wx/gdicmn.h> 32 virtual void setA(
int a ) = 0;
33 virtual int getA()
const = 0;
34 virtual const int&
getA2()
const {
return m_a; }
36 virtual void setPoint(
const wxPoint& p ) { m_p = p; }
41 const wxPoint&
getPoint()
const {
return m_p; }
54 void setA(
int a )
override { m_a = a; }
55 int getA()
const override {
return m_a; }
57 void setC(
int a ) { m_c = a; }
58 int getC()
const {
return m_c; }
79 class D :
public A,
public C 85 virtual void setA(
int a )
override { m_aa = 2 * a; }
86 virtual int getA()
const override {
return m_aa; }
160 .Map( D::enum_class::TESTA,
"TESTA" )
161 .Map( D::enum_class::TESTB,
"TESTB" )
162 .Map( D::enum_class::TESTC,
"TESTC" );
179 cond->SetAvailableFunc( [=](
INSPECTABLE* aItem)->
bool {
return *aItem->
Get<
int>(
"A" ) > 50; } );
191 wxArrayString labels;
194 wxPGChoices newChoices( labels, values );
199 prop->SetChoices( newChoices );
232 ptr->Set(
"A", 100 );
233 ptr->Set(
"point", wxPoint( 100, 200 ) );
234 BOOST_CHECK_EQUAL( *ptr->Get<
int>(
"A" ), 100 );
235 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point" ), wxPoint( 100, 200 ) );
239 ptr->Set(
"enumClass", D::enum_class::TESTC );
241 BOOST_CHECK_EQUAL( *ptr->Get<
D::enum_class>(
"enumClass" ), D::enum_class::TESTC );
250 BOOST_CHECK_EQUAL( *ptr->Get<
int>(
"A" ), 23 );
254 BOOST_CHECK_EQUAL( *ptr->Get<
int>(
"A" ), 46 );
261 BOOST_CHECK_EQUAL( ptr->Set<
int>(
"does not exist", 5 ),
false );
269 BOOST_CHECK_THROW( ptr->Get<wxPoint>(
"A" ), std::invalid_argument );
277 BOOST_CHECK_EQUAL( D_to_A, dynamic_cast<A*>( ptr ) );
280 BOOST_CHECK_EQUAL( D_to_C, dynamic_cast<C*>( ptr ) );
292 wxArrayString labels;
293 labels.Add(
"TEST1" );
294 labels.Add(
"TEST2" );
295 labels.Add(
"TEST3" );
297 const wxPGChoices& v = prop->
Choices();
298 BOOST_CHECK_EQUAL( v.GetCount(), values.GetCount() );
299 BOOST_CHECK_EQUAL( v.GetCount(), labels.GetCount() );
301 for (
int i = 0; i < values.GetCount(); ++i )
303 BOOST_CHECK_EQUAL( v.GetValue( i ), values[i] );
306 for (
int i = 0; i < labels.GetCount(); ++i )
308 BOOST_CHECK_EQUAL( v.GetLabel( i ), labels[i] );
315 wxAny any = item.
Get( prop );
316 BOOST_CHECK_EQUAL( any.GetAs<wxString>( &str ),
false );
319 any = item.
Get( prop );
320 BOOST_CHECK_EQUAL( any.GetAs<wxString>( &str ),
true );
329 values.Add( D::enum_class::TESTA );
330 values.Add( D::enum_class::TESTB );
331 values.Add( D::enum_class::TESTC );
332 wxArrayString labels;
333 labels.Add(
"TESTA" );
334 labels.Add(
"TESTB" );
335 labels.Add(
"TESTC" );
337 const wxPGChoices& v = prop->
Choices();
338 BOOST_CHECK_EQUAL( v.GetCount(), values.GetCount() );
339 BOOST_CHECK_EQUAL( v.GetCount(), labels.GetCount() );
341 for (
int i = 0; i < values.GetCount(); ++i )
343 BOOST_CHECK_EQUAL( v.GetValue( i ), values[i] );
346 for (
int i = 0; i < labels.GetCount(); ++i )
348 BOOST_CHECK_EQUAL( v.GetLabel( i ), labels[i] );
371 ptr->Set(
"point", wxPoint( 100, 100 ) );
372 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point" ), wxPoint( 100, 100 ) );
373 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point_alias" ), wxPoint( 100, 100 ) );
375 ptr->Set(
"point_alias", wxPoint( 300, 300 ) );
376 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point" ), wxPoint( 300, 300 ) );
377 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point_alias" ), wxPoint( 300, 300 ) );
385 prop = propMgr.GetProperty(
TYPE_HASH(
D ),
"bool" );
386 BOOST_CHECK_EQUAL( prop,
nullptr );
388 prop = propMgr.GetProperty(
TYPE_HASH(
D ),
"replaced_bool" );
401 wxArrayString labels;
405 const wxPGChoices& v = prop->
Choices();
406 BOOST_CHECK_EQUAL( v.GetCount(), values.GetCount() );
407 BOOST_CHECK_EQUAL( v.GetCount(), labels.GetCount() );
409 for (
int i = 0; i < values.GetCount(); ++i )
411 BOOST_CHECK_EQUAL( v.GetValue( i ), values[i] );
414 for (
int i = 0; i < labels.GetCount(); ++i )
416 BOOST_CHECK_EQUAL( v.GetLabel( i ), labels[i] );
420 BOOST_AUTO_TEST_SUITE_END()
const wxPoint & getPoint() const
virtual int getA() const =0
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
static PROPERTY_MANAGER & Instance()
static struct ENUM_GLOB_DESC _ENUM_GLOB_DESC
static struct CLASS_E_DESC _CLASS_E_DESC
enum_glob getGlobEnum() const
static ENUM_MAP< T > & Instance()
static struct CLASS_C_DESC _CLASS_C_DESC
enum_class getClassEnum() const
BOOST_CHECK(v2.Cross(v1)==1)
static struct CLASS_A_DESC _CLASS_A_DESC
void setPoint3(wxPoint p)
virtual int getA() const override
wxAny Get(PROPERTY_BASE *aProperty)
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void setClassEnum(enum_class val)
const wxPoint & getPoint4() const
Class that other classes need to inherit from, in order to be inspectable.
virtual void setA(int a) override
virtual const wxPGChoices & Choices() const
Return a limited set of possible values (e.g.
BOOST_AUTO_TEST_CASE(Init)
PROPERTY_MANAGER & propMgr
void setGlobEnum(enum_glob val)
static struct CLASS_B_DESC _CLASS_B_DESC
wxPoint getPoint2() const
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
void AddProperty(PROPERTY_BASE *aProperty)
Register a property.
bool Available(INSPECTABLE *aObject) const
Return true if aObject offers this PROPERTY.
void setA(int a) override
void ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew)
Replace an existing property for a specific type.
static struct CLASS_D_DESC _CLASS_D_DESC
Provide class metadata.Helper macro to map type hashes to names.
virtual void setA(int a)=0
int getA() const override
void setPoint4(wxPoint p)
virtual const int & getA2() const
virtual void setPoint(const wxPoint &p)
void setPoint2(wxPoint &p)