Menu

AutomatedBehaviour

Anonymous Johan Luisier

Navigate through the wiki

In the following text, a the following class is assumed:

    class MyClass : public MyParentClass

This class is assumed to have members:

     type MyMember;
     anotherType MyOtherMember;
     // yetAnotherType MyInheritedMember is inherited from MyParentClass

and a method

     bool myMethod( const int& arg1, unsigned& arg2 ) const;

Automated behaviours are a key feature of XmlCppClassGenerator: for instance automatic methods can be generated from the class members, the constructors' bodies are generated from the parent class(es) and the members, and the comments can also be generated automatically (partially of course, XmlCppClassGenerator will not guess what you want to be written in the comment) for instance.

Table of contents:

  • Automatic methods
  • Automatic body construction
  • Comments

Automatic methods

For each member added to a class, up to four method can be added automatically, without any additional <method> elements. These methods are:

  • the "standard getter", i.e.
        const type& myMember() const;

is created, with an appropriated comment.
* the "standard setter", i.e.

        void setMyMember( const type& myMember );

is created with correct comment.
* the "pointer getter", i.e.

        const type* myMemberPtr() const;

is created with correct comment.
* the "pointer setter", i.e.

        void setMyMemberPtr( const type* myMember );

is created with correct comment.

Unrelated to member, there are other automatic methods:

  • A virtual destructor is created, i.e.
        virtual ~!MyClass();
  • the affectation operator, i.e.
         MyClass& operator=( const MyClass myClass );
  • The comparison operator, i.e.
         MyClass& MyClass::operator==( const MyClass& myClass ) const;

Back on top

Automatic body construction

For any generated constructor, the following body will be created:

     MyClass::MyClass( /* any arguments */ )
      : MyParentClass( ), MyMember( ), MyOtherMember( )
     {}

Additionally, a copy constructor can be added, and it body it also automatically generated:

     MyClass::MyClass( const MyClass& myClass )
      : MyParentClass( myClass ), MyMember( myClass.myMember() ), MyOtherMember( myClass.myOtherMember() )
     {}

The affectation operator body is:

     MyClass& MyClass::operator=( const MyClass& myClass )
     {
       this -> MyParentClass::operator=( myClass );
       MyMember = myClass.myMember();
       MyOtherMember = myClass.myOtherMember();
       return *this;
     }

The comparison operator is:

     MyClass& MyClass::operator==( const MyClass& myClass ) const
     {
       if ( ! this -> MyParentClass::operator==( myClass ) )
         return false;
       if ( MyMember == myClass.myMember() && 
            MyOtherMember == myClass.myOtherMember() )
         return true;
       return false;
     }

Back on top

Comments

For each constructor, method and member a minimalist doxygen comment is added if <comments> false </comments> is not present in the XML class description file. For the members, the comments are empty, i.e.:

     /** 
      * 
      */

For methods, the list of arguments is used:

     /** 
      * 
      * @param[in] arg1
      * @param[out] arg2
      */
     bool myMethod( const int& arg1, unsigned& arg2 ) const;

Note that the [in]/[out] option is guessed from the const and & type modifier of the argument, which can lead to wrong identification.

For constructors / destructor, the first list contains either "Constructor" or "Destructor" (or the appropriate translation).

Back on top


Related

Wiki: AutomatedBehaviour
Wiki: WikiMap

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.