Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Macros
Teuchos_StandardMemberCompositionMacros.hpp File Reference

Macro that adds <<std member="" comp>="">> members as attribute members for any class. More...

#include "Teuchos_ConfigDefs.hpp"
Include dependency graph for Teuchos_StandardMemberCompositionMacros.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 Teuchos
 

Macros

#define STANDARD_MEMBER_COMPOSITION_MEMBERS(TYPE, NAME)
 Macro that adds <<std member="" comp>="">> attributes to any class. More...
 

Detailed Description

Macro that adds <<std member="" comp>="">> members as attribute members for any class.

Definition in file Teuchos_StandardMemberCompositionMacros.hpp.

Macro Definition Documentation

#define STANDARD_MEMBER_COMPOSITION_MEMBERS (   TYPE,
  NAME 
)
Value:
void NAME ( const TYPE & NAME ## _in ) { NAME ## _ = NAME ## _in ; }\
const TYPE& NAME() const { return NAME ## _; }\
private:\
TYPE NAME ## _;\
public: \
typedef ::Teuchos::DummyDummyClass NAME ## DummyDummyClass_t

Macro that adds <<std member="" comp>="">> attributes to any class.

For example, if you want to include a <<std member="" comp>="">> attribute as a member object of type MyClass with the name my_attribute you would include the macro in the public section of YourClass declaration as follows:

 class YourClass {
 public:
   STANDARD_MEMBER_COMPOSITION_MEMBERS( MyClass, my_attribute );
 };

This macro adds the following data member to the class declaration:

       private:
               MyClass my_attribute_;

and the following methods to your class declaration:

 public:
 void my_attribute( const My_Class & my_attribute_in )
   { my_attribute_ = my_attribute_in; }
 const My_Class& my_attribute() const
   { return my_attribute_; }

The advantage of using this type of declaration is that it saves you a lot of typing and space. Later if you need to override these operations you can just implement the member functions by hand.

Definition at line 86 of file Teuchos_StandardMemberCompositionMacros.hpp.