32 virtual void setA(
int a ) = 0;
33 virtual int getA()
const = 0;
34 virtual const int&
getA2()
const {
return m_a; }
79class 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; }
112 .Map( enum_glob::TEST1,
"TEST1" )
113 .Map( enum_glob::TEST2,
"TEST2" )
114 .Map( enum_glob::TEST3,
"TEST3" );
180 cond->SetAvailableFunc( [=](
INSPECTABLE* aItem)->
bool {
181 return *aItem->
Get<
enum_glob>(
"enumGlob" ) == enum_glob::TEST1;
192 values.Add( enum_glob::TEST1 );
193 values.Add( enum_glob::TEST3 );
194 wxArrayString labels;
197 wxPGChoices newChoices( labels, values );
202 prop->SetChoices( newChoices );
235 ptr->Set(
"A", 100 );
236 ptr->Set(
"point", wxPoint( 100, 200 ) );
237 BOOST_CHECK_EQUAL( *ptr->Get<
int>(
"A" ), 100 );
238 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point" ), wxPoint( 100, 200 ) );
253 BOOST_CHECK_EQUAL( *ptr->Get<
int>(
"A" ), 23 );
257 BOOST_CHECK_EQUAL( *ptr->Get<
int>(
"A" ), 46 );
264 BOOST_CHECK_EQUAL( ptr->Set<
int>(
"does not exist", 5 ),
false );
265 BOOST_CHECK_EQUAL(
static_cast<bool>( ptr->Get<
int>(
"neither" ) ),
false );
272 BOOST_CHECK_THROW( ptr->Get<wxPoint>(
"A" ), std::invalid_argument );
280 BOOST_CHECK_EQUAL( D_to_A,
dynamic_cast<A*
>( ptr ) );
283 BOOST_CHECK_EQUAL( D_to_C,
dynamic_cast<C*
>( ptr ) );
295 wxArrayString labels;
296 labels.Add(
"TEST1" );
297 labels.Add(
"TEST2" );
298 labels.Add(
"TEST3" );
300 const wxPGChoices& v = prop->
Choices();
301 BOOST_CHECK_EQUAL( v.GetCount(), values.GetCount() );
302 BOOST_CHECK_EQUAL( v.GetCount(), labels.GetCount() );
304 for (
unsigned int i = 0; i < values.GetCount(); ++i )
306 BOOST_CHECK_EQUAL( v.GetValue( i ), values[i] );
309 for (
unsigned int i = 0; i < labels.GetCount(); ++i )
311 BOOST_CHECK_EQUAL( v.GetLabel( i ), labels[i] );
318 wxAny any = item.
Get( prop );
319 BOOST_CHECK_EQUAL( any.GetAs<wxString>( &str ),
false );
322 any = item.
Get( prop );
323 BOOST_CHECK_EQUAL( any.GetAs<wxString>( &str ),
true );
335 wxArrayString labels;
336 labels.Add(
"TESTA" );
337 labels.Add(
"TESTB" );
338 labels.Add(
"TESTC" );
340 const wxPGChoices& v = prop->
Choices();
341 BOOST_CHECK_EQUAL( v.GetCount(), values.GetCount() );
342 BOOST_CHECK_EQUAL( v.GetCount(), labels.GetCount() );
344 for (
unsigned int i = 0; i < values.GetCount(); ++i )
346 BOOST_CHECK_EQUAL( v.GetValue( i ), values[i] );
349 for (
unsigned int i = 0; i < labels.GetCount(); ++i )
351 BOOST_CHECK_EQUAL( v.GetLabel( i ), labels[i] );
363 BOOST_CHECK( !propCond->
Available( ptr ) );
366 BOOST_CHECK( propCond->
Available( ptr ) );
374 ptr->Set(
"point", wxPoint( 100, 100 ) );
375 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point" ), wxPoint( 100, 100 ) );
376 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point_alias" ), wxPoint( 100, 100 ) );
378 ptr->Set(
"point_alias", wxPoint( 300, 300 ) );
379 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point" ), wxPoint( 300, 300 ) );
380 BOOST_CHECK_EQUAL( *ptr->Get<wxPoint>(
"point_alias" ), wxPoint( 300, 300 ) );
388 prop = propMgr.GetProperty(
TYPE_HASH(
D ),
"bool" );
389 BOOST_CHECK_EQUAL( prop,
nullptr );
391 prop = propMgr.GetProperty(
TYPE_HASH(
D ),
"replaced_bool" );
404 wxArrayString labels;
408 const wxPGChoices& v = prop->
Choices();
409 BOOST_CHECK_EQUAL( v.GetCount(), values.GetCount() );
410 BOOST_CHECK_EQUAL( v.GetCount(), labels.GetCount() );
412 for (
unsigned int i = 0; i < values.GetCount(); ++i )
414 BOOST_CHECK_EQUAL( v.GetValue( i ), values[i] );
417 for (
unsigned int i = 0; i < labels.GetCount(); ++i )
419 BOOST_CHECK_EQUAL( v.GetLabel( i ), labels[i] );
void setPoint2(wxPoint &p)
virtual const int & getA2() const
virtual void setPoint(const wxPoint &p)
const wxPoint & getPoint4() const
virtual int getA() const =0
void setPoint3(wxPoint p)
virtual void setA(int a)=0
void setPoint4(wxPoint p)
wxPoint getPoint2() const
const wxPoint & getPoint() const
int getA() const override
void setA(int a) override
virtual int getA() const override
enum_glob getGlobEnum() const
enum_class getClassEnum() const
virtual void setA(int a) override
void setGlobEnum(enum_glob val)
void setClassEnum(enum_class val)
static ENUM_MAP< T > & Instance()
Class that other classes need to inherit from, in order to be inspectable.
wxAny Get(PROPERTY_BASE *aProperty) const
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
bool Available(INSPECTABLE *aObject) const
Return true if aObject offers this PROPERTY.
virtual const wxPGChoices & Choices() const
Return a limited set of possible values (e.g.
Provide class metadata.Helper macro to map type hashes to names.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
PROPERTY_MANAGER & propMgr
BOOST_AUTO_TEST_SUITE_END()
static struct ENUM_GLOB_DESC _ENUM_GLOB_DESC
static struct CLASS_A_DESC _CLASS_A_DESC
static struct CLASS_D_DESC _CLASS_D_DESC
BOOST_AUTO_TEST_CASE(Init)
static struct CLASS_C_DESC _CLASS_C_DESC
static struct CLASS_E_DESC _CLASS_E_DESC
static struct CLASS_B_DESC _CLASS_B_DESC