Menu

Welcome to Activities

Activities
Colin
2009-12-06
2013-04-26
  • Colin

    Colin - 2009-12-06

    Welcome to Activities

     
  • Colin

    Colin - 2009-12-08

    Just added some new data types into the data folder of the project.
    Now have Pair, Triple, Quad, OneOfPair and OneOfType.

    OneOfPair and OneOfType allow compile time boolean type selection.

    sample code:

        ocl::OneOfType<double, long, IsDecimal>::type value;
        value = IsDecimal ? 1.5 : 1;

     
  • Colin

    Colin - 2010-02-06

    Nearing completion of the TypeInfo template class…

    Features include the following:

        naming, e.g.

            TypeInfo<int>::Name
    

        character manipulation, e.g.

            TypeInfo<char>::NullChar or TypeInfo<wchar_t>::NullChar, which equates to '\0' or L'\0'
    

        type filtering, e.g.

            TypeInfo<int*>::raw_type, which equates to int
            TypeInfo<int*>::reference_type, which equates to int*&
            TypeInfo<TypeInfo<int*>::raw_type>::reference_type, which equates to int&
            TypeInfo<int&>::pointer_type, which equates to int*
    

        Type ordering, e.g.

            TypeInfo<short>::next_type, which equates to int
            TypeInfo<double>::prev_type, which equates to float
    

    TypeInfo class also provides many more features, such as IsInteger, IsDecimal, IsLarger, IsSmaller, IsSigned, etc.

     
  • Colin

    Colin - 2010-03-25

    http://cppocl.co.uk is now up and running, although under development.
    Patience please, so much to do…

     
  • Colin

    Colin - 2010-05-03

    C++ properties have been re-implemented to be simpler to use.

    This is the c# equivalent:

    class TimePeriod
    {
        private double seconds;
        public double Hours
        {
            get { return seconds / 3600; }
            set { seconds = value * 3600; }
        }
    }
    

    This is the C++ version implemented without using macros:

    class TimePeriod
    {
    private:
        double seconds;
    public:
        Property<TimePeriod, double, ocl::ePropertyReadWrite /*this is the default if not specified*/> Hours;
        const double& GetHours() const { return seconds / 3600; }
        void SetHours(const double& value) { seconds = value * 3600; }
    public:
        TimePeriod() : Hours(this, &TimePeriod::GetHours, &TimePeriod::SetHours)
    };
    
     
  • Colin

    Colin - 2010-05-03

    There are also some version of the C++ properties using macros.

    class TimePeriod
    {
    private:
        double seconds;
    // property will be public
        OCL_PROPERTY(TimePeriod, double, Hours);
        OCL_PROPERTY_GET(Hours) { return seconds / 3600; }
        OCL_PROPERTY_SET(Hours) { seconds = value * 3600; }
    public:
        TimePeriod() : OCL_PROPERTY_LINK(Hours)
    };
    

    This is the C++ read-only version implemented using macros:

    class TimePeriod
    {
    private:
        double seconds;
    // property will be public
        OCL_PROPERTY_READONLY(TimePeriod, double, Hours) { return seconds / 3600; }
    public:
        TimePeriod() : OCL_PROPERTY_LINK(Hours)
    };
    

    This is the C++ write-only version implemented using macros:

    class TimePeriod
    {
    private:
        double seconds;
    // property will be public
        OCL_PROPERTY_WRITEONLY(TimePeriod, double, Hours) { seconds = value * 3600; }
    public:
        TimePeriod() : OCL_PROPERTY_LINK(Hours)
    };
    
     
  • Colin

    Colin - 2010-05-03

    There is also a macro called OCL_PROPERTY_LINK_CLASS which can be used instead of using the Property constructor manually to initialise the property object.

    e.g.
    instead of:
    TimePeriod() : Hours(this, &TimePeriod::GetHours, &TimePeriod::SetHours)

    could use:
    TimePeriod() : OCL_PROPERTY_LINK_CLASS(TimePeriod, Hours)

    When using the property, it would be the same as C#, e.g.

    TimePeriod tp;
    tp.Hours = 3;
    double hrs = tp.Hours;

    break points can then be used within the get and set methods if required, when debugging.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.