Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 346397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:10:23+00:00 2026-05-12T11:10:23+00:00

I’ve already implemented, using macros, a C++ property system that satisfied the following requirements:

  • 0

I’ve already implemented, using macros, a C++ property system that satisfied the following requirements:

  • Property can be referenced using a integeral key
  • Property can be accessed via a generic Set/Get
  • Properties (and property keys) must be inheritable
  • Properties can be registered with getters/setters

and is implemented as follows

  • Each property belongs to a class
  • Each property is ‘declared’ with a key unique to it’s inheritance chain. (Implemented using a rather clever __ COUNTER __ hack). It has the following characteristic
    • A root class (no parents) start numbering its properties from 0
    • A child class will start numbering its properties from the parent’s last id + 1

class A
{    
    static const unsigned int Property_0 = GET_KEY_MACRO; //expands to 0
    static const unsigned int Property_1 = GET_KEY_MACRO; //expands to 1     
};
class B : public A
{    
    static const unsigned int Property_0 = GET_KEY_MACRO(A); //expands to 2
    //and so forth    
};
class C : public A
{
     static const unsigned int Property_0 = GET_KEY_MACRO(A); //expands to 2. different inheritance chain
};

  • Other code can refer to the property using the static constant id.

objectinstance.SetValue(C::Property_0, 5)

  • Each property is ‘registered’ by using a macro that expands to a virtual method. The macro currently allows for a property type, a getter, and a setter to be registered

BEGIN_PROPERTIES
    REG_PROP(Property_0, int)
    REG_PROP_G(Property_1, int, getterFunc)
    ...
END_PROPERTIES

//expands to 

virtual void registerProperties()
{
    register(blah, blah, ...)
}

  • SetValue/GetValue that takes a property key and does some background magic to set/get it(already implemented)

Can anyone think of template based approach that’s equivalent/simpler to the above system?

Note: This property system is to designed for remote RPCish calls as well as fast local access.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:10:23+00:00Added an answer on May 12, 2026 at 11:10 am

    This looks like a classic game property system so I’m going to recommend you read this Gamasutra article about a good system that doesn’t require too much gunk around your code. Also have a look at boost.fusion and see if it can’t help you.

    What follows is my opinion and can be ignored for the sake of the question:

    That said I’m not really sure what you’d gain by using templates. Is it just that “Macros Are Bad”?

    Having worked with a bunch of these systems I’ve come to the conclusion that you’re often solving the wrong problem by adding a property system. If you can, consider using a language like C# where properties are first-class language feature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.