field_property_get Class Template Reference
[Properties Library]

#include <stlsoft/properties/field_properties.hpp>

List of all members.


Detailed Description

template<typename V, typename R, typename C>
class stlsoft::field_property_get< V, R, C >

Class template used to define a read-only internal field property.

class ClassWithReadOnlyProp
{
public: // Member Types
  typedef std::string   string_type;
  typedef int           index_type;

public: // Construction
  ClassWithReadOnlyProp(char const* instanceName, index_type instanceIndex)
    : name(instanceName)  // Property value can be initialised inside enclosing class
    , index(1)            // Property value can be initialised inside enclosing class
  {}

public: // Operations
  void ReBadge(char const* newInstanceName, index_type newInstanceIndex)
  {
    name  = newInstanceName;  // Property value can be assigned inside enclosing class
    index = newInstanceIndex; // Property value can be assigned inside enclosing class
  }

public: // Properties
  stlsoft::field_property_get<index_type, index_type, ClassWithReadOnlyProp>          index;
  stlsoft::field_property_get<string_type, string_type const&, ClassWithReadOnlyProp> name;
};

. . .

ClassWithReadOnlyProp   c("Object-#1", 1);

int                 index   =   c.index;    // Ok: access the value of the read-only property
std::string const   &name   =   c.name;     // Ok: access the value of the read-only property

c.index =   2;          // Compile error: cannnot write to the read-only property
c.name  =   "new name"; // Compile error: cannnot write to the read-only property
Examples:

by_library/properties/field_property_get/field_property_get.cpp, by_library/properties/field_property_set/field_property_set.cpp, and by_library/properties/properties/properties.cpp.


Public Types

typedef V value_type
typedef R reference_type
typedef C container_type
typedef field_property_get< V,
R, C > 
class_type

Public Member Functions

 operator reference_type () const
 Provides read-only access to the property.

Member Function Documentation

operator reference_type (  )  const [inline]

Provides read-only access to the property.


The documentation for this class was generated from the following file:

Generated on Thu Jun 10 08:58:55 2010 for STLSoft by  doxygen 1.5.6