Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
a7d3ab2c
Commit
a7d3ab2c
authored
Dec 15, 2009
by
schurade
Browse files
[DOKU] improved doku
parent
512a0c78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
325 additions
and
4 deletions
+325
-4
src/common/WProperties.h
src/common/WProperties.h
+146
-1
src/common/WProperty.h
src/common/WProperty.h
+179
-3
No files found.
src/common/WProperties.h
View file @
a7d3ab2c
...
...
@@ -45,7 +45,7 @@ public:
/**
* standard constructor
*/
explicit
WProperties
();
WProperties
();
/**
* destructor
...
...
@@ -54,11 +54,15 @@ public:
/**
* sets a flag hidden, which can be used by the datasetbrowser for instance
*
* \param name of the property to hide
*/
void
hideProperty
(
std
::
string
name
);
/**
* sets a flag hidden, which can be used by the datasetbrowser for instance
*
* \param name name of the property to unhide
*/
void
unhideProperty
(
std
::
string
name
);
...
...
@@ -67,23 +71,118 @@ public:
*/
std
::
vector
<
WProperty
*
>&
getPropertyVector
();
/**
* adds a boolean property to the list of properties
*
* \param name of the property
* \param value of the property
* \param hidden true if hidden from automatic widget generation
* \param shortDesc short description
* \param longDesc long description
*
* \return pointer to boost signal object that is fired whern a property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
addBool
(
std
::
string
name
,
bool
value
=
false
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* adds a char property to the list of properties
*
* \param name of the property
* \param value of the property
* \param hidden true if hidden from automatic widget generation
* \param shortDesc short description
* \param longDesc long description
*
* \return pointer to boost signal object that is fired whern a property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
addChar
(
std
::
string
name
,
char
value
=
0
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* adds an integer property to the list of properties
*
* \param name of the property
* \param value of the property
* \param hidden true if hidden from automatic widget generation
* \param shortDesc short description
* \param longDesc long description
*
* \return pointer to boost signal object that is fired whern a property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
addInt
(
std
::
string
name
,
int
value
=
0
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* adds a float property to the list of properties
*
* \param name of the property
* \param value of the property
* \param hidden true if hidden from automatic widget generation
* \param shortDesc short description
* \param longDesc long description
*
* \return pointer to boost signal object that is fired whern a property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
addFloat
(
std
::
string
name
,
float
value
=
0.0
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* adds a double property to the list of properties
*
* \param name of the property
* \param value of the property
* \param hidden true if hidden from automatic widget generation
* \param shortDesc short description
* \param longDesc long description
*
* \return pointer to boost signal object that is fired whern a property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
addDouble
(
std
::
string
name
,
double
value
=
0.0
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* adds a string property to the list of properties
*
* \param name of the property
* \param value of the property
* \param hidden true if hidden from automatic widget generation
* \param shortDesc short description
* \param longDesc long description
*
* \return pointer to boost signal object that is fired whern a property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
addString
(
std
::
string
name
,
std
::
string
value
=
""
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* adds a color property to the list of properties
*
* \param name of the property
* \param value of the property
* \param hidden true if hidden from automatic widget generation
* \param shortDesc short description
* \param longDesc long description
*
* \return pointer to boost signal object that is fired whern a property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
addColor
(
std
::
string
name
,
WColor
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* getter for the value of a property as std string
*
* \param prop the name of the property
* \return string of property
*/
std
::
string
getValueString
(
const
std
::
string
prop
);
/**
* sets the value of an existing property
*
* \param prop string with name of property
* \param arg value
*/
template
<
typename
T
>
void
setValue
(
std
::
string
prop
,
const
T
&
arg
)
{
boost
::
shared_lock
<
boost
::
shared_mutex
>
slock
;
...
...
@@ -97,6 +196,12 @@ public:
slock
.
unlock
();
}
/**
* sets the minimum value of an existing property
*
* \param prop string with name of property
* \param arg value
*/
template
<
typename
T
>
void
setMin
(
std
::
string
prop
,
const
T
&
arg
)
{
if
(
findProp
(
prop
)
)
...
...
@@ -105,6 +210,12 @@ public:
}
}
/**
* sets the maximum value of an existing property
*
* \param prop string with name of property
* \param arg value
*/
template
<
typename
T
>
void
setMax
(
std
::
string
prop
,
const
T
&
arg
)
{
if
(
findProp
(
prop
)
)
...
...
@@ -113,6 +224,12 @@ public:
}
}
/**
* returns the value of an existing property
*
* \param prop name of the property
* \return the value
*/
template
<
typename
T
>
T
getValue
(
std
::
string
prop
)
{
if
(
findProp
(
prop
)
)
...
...
@@ -124,6 +241,12 @@ public:
return
0
;
}
/**
* returns the minimum value of an existing property
*
* \param prop name of the property
* \return the minimum value
*/
template
<
typename
T
>
T
getMin
(
std
::
string
prop
)
{
if
(
findProp
(
prop
)
)
...
...
@@ -135,6 +258,12 @@ public:
return
0
;
}
/**
* returns the maximum value of an existing property
*
* \param prop name of the property
* \return the maximum value
*/
template
<
typename
T
>
T
getMax
(
std
::
string
prop
)
{
if
(
findProp
(
prop
)
)
...
...
@@ -148,12 +277,28 @@ public:
private:
/**
* helper function that finds a property by its name
*
* \param name
* \return pointer to a WProperty object
*/
WProperty
*
findProp
(
std
::
string
name
);
/**
* map of properties for easy access with name string
*/
std
::
map
<
std
::
string
,
WProperty
*
>
m_propertyList
;
/**
* vector of properties to retain the order of creation so that widgets created from this
* properties object always look the same
*/
std
::
vector
<
WProperty
*
>
m_propertyVector
;
/**
* boost mutex object for thread safety of updating of properties
*/
boost
::
shared_mutex
m_updateLock
;
};
...
...
src/common/WProperty.h
View file @
a7d3ab2c
...
...
@@ -55,13 +55,73 @@ class WProperty
public:
/**
* constructors
*
* \param name String with name of property
* \param value value of the property
* \param hidden true if property shouldn't appear in automatically created control widgets
* \param shortDesc short description of the property
* \param longDesc long description of the property
*/
WProperty
(
std
::
string
name
,
std
::
string
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* constructors
*
* \param name String with name of property
* \param value value of the property
* \param hidden true if property shouldn't appear in automatically created control widgets
* \param shortDesc short description of the property
* \param longDesc long description of the property
*/
WProperty
(
std
::
string
name
,
bool
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* constructors
*
* \param name String with name of property
* \param value value of the property
* \param hidden true if property shouldn't appear in automatically created control widgets
* \param shortDesc short description of the property
* \param longDesc long description of the property
*/
WProperty
(
std
::
string
name
,
char
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* constructors
*
* \param name String with name of property
* \param value value of the property
* \param hidden true if property shouldn't appear in automatically created control widgets
* \param shortDesc short description of the property
* \param longDesc long description of the property
*/
WProperty
(
std
::
string
name
,
int
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* constructors
*
* \param name String with name of property
* \param value value of the property
* \param hidden true if property shouldn't appear in automatically created control widgets
* \param shortDesc short description of the property
* \param longDesc long description of the property
*/
WProperty
(
std
::
string
name
,
float
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* constructors
*
* \param name String with name of property
* \param value value of the property
* \param hidden true if property shouldn't appear in automatically created control widgets
* \param shortDesc short description of the property
* \param longDesc long description of the property
*/
WProperty
(
std
::
string
name
,
double
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
* constructors
*
* \param name String with name of property
* \param value value of the property
* \param hidden true if property shouldn't appear in automatically created control widgets
* \param shortDesc short description of the property
* \param longDesc long description of the property
*/
WProperty
(
std
::
string
name
,
WColor
value
,
bool
hidden
=
false
,
std
::
string
shortDesc
=
""
,
std
::
string
longDesc
=
""
);
/**
...
...
@@ -69,22 +129,77 @@ public:
*/
virtual
~
WProperty
();
/**
* getter for type
*
* \return property type
*/
PropertyType
getType
();
/**
* getter for name
*
* \return name of property
*/
std
::
string
getName
();
/**
* setter for short description
*
* \param desc description string
*/
void
setShortDesc
(
const
std
::
string
desc
);
/**
* setter for long description
*
* \param desc description string
*/
void
setLongDesc
(
const
std
::
string
desc
);
/**
* hides property
*/
void
hide
();
/**
* unhides property
*/
void
unhide
();
/**
* true if property is hidden
*
* \return bool
*/
bool
isHidden
();
/**
* getter for short description
*
* \return string with description
*/
std
::
string
getShortDesc
();
/**
* getter for long description
*
* \return string with long description
*/
std
::
string
getLongDesc
();
/**
* getter for the boost signal object that indicates a changed property
*
* \return signal object
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>*
getSignalValueChanged
();
/**
* setter for value
*
* \param arg the value
*/
template
<
typename
T
>
void
setValue
(
const
T
&
arg
)
{
try
...
...
@@ -98,6 +213,11 @@ public:
m_signalValueChanged
(
m_name
);
}
/**
* setter for minimum boundary
*
* \param arg the minimum value specified for the property
*/
template
<
typename
T
>
void
setMin
(
const
T
&
arg
)
{
try
...
...
@@ -110,6 +230,11 @@ public:
}
}
/**
* setter for maximum boundary
*
* \param arg the maximum value specified for the property
*/
template
<
typename
T
>
void
setMax
(
const
T
&
arg
)
{
try
...
...
@@ -122,36 +247,87 @@ public:
}
}
/**
* getter for value
*
* \return the value
*/
template
<
typename
T
>
T
getValue
()
{
return
boost
::
lexical_cast
<
T
>
(
m_value
);
}
/**
* getter for minimum value
*
* \return the minimum value
*/
template
<
typename
T
>
T
getMin
()
{
return
boost
::
lexical_cast
<
T
>
(
m_min
);
}
/**
* getter for maximum value
*
* \return the maximum value
*/
template
<
typename
T
>
T
getMax
()
{
return
boost
::
lexical_cast
<
T
>
(
m_max
);
}
/**
* getter for value as string, all value are stored internally as std::strings
*
* \return string with value
*/
std
::
string
getValueString
();
private:
/**
* type of property
*/
PropertyType
m_type
;
/**
* name of property
*/
std
::
string
m_name
;
/**
* value of property
*/
std
::
string
m_value
;
/**
* minimum value of property
*/
std
::
string
m_min
;
/**
* maximum value of property
*/
std
::
string
m_max
;
/**
* short description
*/
std
::
string
m_shortDesc
;
/**
* long description
*/
std
::
string
m_longDesc
;
/**
* flag if property should be hidden from automatic widget creation
*/
bool
m_isHidden
;
/**
* boost signal object to indicate property changes
*/
boost
::
signals2
::
signal1
<
void
,
std
::
string
>
m_signalValueChanged
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment