Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
2669cd6854 | |||
aa8a3333fe | |||
44f5b8ab5f | |||
2568c690cf | |||
05e1d7d2d7 | |||
dfaa1bd035 | |||
5907ee7abd | |||
5346b024ff |
1
authors.txt
Normal file
1
authors.txt
Normal file
@@ -0,0 +1 @@
|
||||
MR Edouard DUPIN <yui.heero@gmail.com>
|
65
doc/build.md
Normal file
65
doc/build.md
Normal file
@@ -0,0 +1,65 @@
|
||||
Build lib & build sample {#eproperty_build}
|
||||
========================
|
||||
|
||||
@tableofcontents
|
||||
|
||||
Download: {#eproperty_build_download}
|
||||
=========
|
||||
|
||||
eproperty use some tools to manage source and build it:
|
||||
|
||||
lutin (build-system): {#eproperty_build_download_lutin}
|
||||
---------------------
|
||||
|
||||
```{.sh}
|
||||
pip install lutin --user
|
||||
# optionnal dependency of lutin (manage image changing size for application release
|
||||
pip install pillow --user
|
||||
```
|
||||
|
||||
|
||||
dependency: {#eproperty_build_download_dependency}
|
||||
-----------
|
||||
|
||||
```{.sh}
|
||||
mkdir framework
|
||||
cd framework
|
||||
git clone https://github.com/atria-soft/elog.git
|
||||
git clone https://github.com/atria-soft/etk.git
|
||||
cd ..
|
||||
```
|
||||
|
||||
sources: {#eproperty_build_download_sources}
|
||||
--------
|
||||
|
||||
```{.sh}
|
||||
cd framework
|
||||
git clone https://github.com/atria-soft/eproperty.git
|
||||
cd ..
|
||||
```
|
||||
|
||||
Build: {#eproperty_build_build}
|
||||
======
|
||||
|
||||
|
||||
library: {#eproperty_build_build_library}
|
||||
--------
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug eproperty
|
||||
```
|
||||
|
||||
Sample: {#eproperty_build_build_sample}
|
||||
-------
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug eproperty-sample
|
||||
```
|
||||
|
||||
|
||||
Run sample: {#eproperty_build_run_sample}
|
||||
===========
|
||||
|
||||
```{.sh}
|
||||
lutin -mdebug eproperty-sample?run
|
||||
```
|
54
doc/mainpage.md
Normal file
54
doc/mainpage.md
Normal file
@@ -0,0 +1,54 @@
|
||||
EPROPERTY library {#mainpage}
|
||||
=================
|
||||
|
||||
@tableofcontents
|
||||
|
||||
What is EPROPERTY: {#eproperty_mainpage_what}
|
||||
==================
|
||||
|
||||
EPROPERTY, or Ewol property interface is a simple property API to set and get generic APIS
|
||||
|
||||
EPROPERTY is designed for
|
||||
- Expose property on generic class
|
||||
- Call class when the parameter change
|
||||
- permit to set value throw string (good for XML configurations)
|
||||
|
||||
|
||||
What languages are supported? {#eproperty_mainpage_language}
|
||||
=============================
|
||||
|
||||
EPROPERTY is written in C++.
|
||||
|
||||
|
||||
Are there any licensing restrictions? {#eproperty_mainpage_license_restriction}
|
||||
=====================================
|
||||
|
||||
EPROPERTY is **FREE software** and _all sub-library are FREE and staticly linkable !!!_
|
||||
|
||||
|
||||
License (APACHE-2.0) {#eproperty_mainpage_license}
|
||||
====================
|
||||
|
||||
Copyright EPROPERTY Edouard DUPIN
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
Other pages {#eproperty_mainpage_sub_page}
|
||||
===========
|
||||
|
||||
- @ref eproperty_build
|
||||
- @ref eproperty_tutorial
|
||||
- [**ewol coding style**](http://atria-soft.github.io/ewol/ewol_coding_style.html)
|
||||
|
||||
|
138
doc/tutorial.md
Normal file
138
doc/tutorial.md
Normal file
@@ -0,0 +1,138 @@
|
||||
Tutorial {#eproperty_tutorial}
|
||||
========
|
||||
|
||||
@tableofcontents
|
||||
|
||||
What is a property: {#eproperty_tutorial_what}
|
||||
===================
|
||||
|
||||
A property is a generic interface to manage parameter of a class whithout redeclare all the time the setter and getter (that is a little boring)
|
||||
|
||||
Calling a property car mermit to be notify when the value change and to control the values range of list ...
|
||||
|
||||
A property can use agreator interface eproperty::interface that declare a **"properties"** variablke that permit to acces at all the property declared.
|
||||
|
||||
Declare a class that have this interface:
|
||||
@snippet sampleAll.cpp eproperty_sample_declare_class_with_interface
|
||||
|
||||
|
||||
Declare property: {#eproperty_tutorial_declare}
|
||||
=================
|
||||
|
||||
We have some basic properties:
|
||||
- eproperty::Value Simple store of a unique Value
|
||||
- eproperty::Range Store a value inside an authorized range
|
||||
- eproperty::List Store a value inside a list of values (set in constructor)
|
||||
|
||||
Declare a Value property: {#eproperty_tutorial_declare_value}
|
||||
-------------------------
|
||||
|
||||
Do the correct include:
|
||||
@snippet sampleAll.cpp eproperty_sample_declare_value
|
||||
|
||||
Declare your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_declare_class_property_value
|
||||
|
||||
Construct the property with eproperty::Interface:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_value
|
||||
|
||||
Construct the property with **NO** eproperty::Interface:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_value2
|
||||
|
||||
Configure your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_use_set_value_1
|
||||
|
||||
Use your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_get_value_value
|
||||
|
||||
|
||||
Declare a Range property: {#eproperty_tutorial_declare_range}
|
||||
-------------------------
|
||||
|
||||
Do the correct include:
|
||||
@snippet sampleAll.cpp eproperty_sample_declare_range
|
||||
|
||||
Declare your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_declare_class_property_range
|
||||
|
||||
Construct the property with eproperty::Interface:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_range
|
||||
|
||||
Construct the property with **NO** eproperty::Interface:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_range2
|
||||
|
||||
Configure your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_use_set_range_1
|
||||
|
||||
Use your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_get_value_range
|
||||
|
||||
|
||||
Declare a List property: {#eproperty_tutorial_declare_list}
|
||||
------------------------
|
||||
|
||||
Do the correct include:
|
||||
@snippet sampleAll.cpp eproperty_sample_declare_list
|
||||
|
||||
Declare your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_declare_class_property_list
|
||||
|
||||
Construct the property with eproperty::Interface:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_list
|
||||
|
||||
Construct the property with **NO** eproperty::Interface:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_list2
|
||||
|
||||
Special case for the List is adding the value with their string assiciated:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_list_add
|
||||
|
||||
Configure your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_use_set_list_1
|
||||
|
||||
Use your property:
|
||||
@snippet sampleAll.cpp eproperty_sample_get_value_list
|
||||
|
||||
|
||||
|
||||
Particularity: {#eproperty_tutorial_particularity}
|
||||
==============
|
||||
|
||||
Define a callback: {#eproperty_tutorial_particularity_callback}
|
||||
------------------
|
||||
|
||||
All property can define a callback, it is used to update class property with special settings.
|
||||
|
||||
The callback is set in the construction instruction like:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_value
|
||||
|
||||
The fucntion define is like:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_value_callback
|
||||
|
||||
It is called every time the Value change, if the value is identical the callback is not called.
|
||||
|
||||
|
||||
Set value without calling the callback: {#eproperty_tutorial_particularity_direct_set}
|
||||
---------------------------------------
|
||||
|
||||
To set a value in a property without calling the nitifiction function, you might use:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_set_direct
|
||||
|
||||
Please do not use it ouside the internal class that define the peoperty (call me if you have an api to control it at the compilation time)
|
||||
|
||||
Heritage and callback: {#eproperty_tutorial_particularity_heritage}
|
||||
----------------------
|
||||
|
||||
When you herit from an other class with theire property you can prefer changing the default value or set an other list of parameter.
|
||||
|
||||
To set value without calling the callback (that can be virtual then ==0 in the initialisation state), you need to call:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_set_direct
|
||||
|
||||
For the eproperty::List, you chan rename enumeration or remove values:
|
||||
@snippet sampleAll.cpp eproperty_sample_initialize_class_property_list_rename
|
||||
|
||||
|
||||
All sample Code: {#eproperty_tutorial_all_code}
|
||||
================
|
||||
|
||||
This Will generate this simple sample code:
|
||||
@snippet sampleAll.cpp eproperty_sample_all
|
34
doxy_eproperty.py
Normal file
34
doxy_eproperty.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import doxy.module as module
|
||||
import doxy.debug as debug
|
||||
import doxy.tools as tools
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name)
|
||||
my_module.set_version("version.txt")
|
||||
my_module.set_title("eproperty: Ewol property interface")
|
||||
my_module.set_website("http://atria-soft.github.io/" + module_name)
|
||||
my_module.set_website_sources("http://github.com/atria-soft/" + module_name)
|
||||
my_module.add_path([
|
||||
module_name,
|
||||
"doc"
|
||||
])
|
||||
my_module.add_depend([
|
||||
'etk'
|
||||
])
|
||||
my_module.add_sample_path([
|
||||
'sample'
|
||||
])
|
||||
my_module.add_exclude_symbols([
|
||||
'*operator<<*',
|
||||
])
|
||||
my_module.add_exclude_file([
|
||||
'debug.h',
|
||||
])
|
||||
my_module.add_file_patterns([
|
||||
'*.h',
|
||||
'*.md',
|
||||
])
|
||||
|
||||
return my_module
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -9,73 +9,16 @@
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <eproperty/InterfaceData.h>
|
||||
|
||||
namespace eproperty {
|
||||
class Property;
|
||||
class Ref;
|
||||
/**
|
||||
* @brief Interface to collect the property list (for abstarction "set" and "get")
|
||||
* It create a simple "properties" member that permit to access at the properties.
|
||||
*/
|
||||
class Interface {
|
||||
friend class eproperty::Property; // to register property in the list.
|
||||
private:
|
||||
std::vector<eproperty::Property*> m_list; //!< list of availlable Propertys (no need to free)
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor.
|
||||
*/
|
||||
Interface();
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~Interface();
|
||||
/**
|
||||
* @brief Register a property class pointer in the List of propertys
|
||||
* @note This class does not destroy the property pointer!!!
|
||||
* @param[in] pointerOnProperty Pointer on the property that might be added.
|
||||
*/
|
||||
void propertyAdd(Property* _pointerOnProperty);
|
||||
/**
|
||||
* @brief Remove all the property reference in this class.
|
||||
* @note no delete, just clean and inform that a property has not been removed.
|
||||
*/
|
||||
void propertyClean();
|
||||
/**
|
||||
* @brief Set a specific value to the property reference name.
|
||||
* @param[in] property The property string name.
|
||||
* @param[in] value The new value of the property (string).
|
||||
* @return true Property update.
|
||||
* @return false Property not update.
|
||||
*/
|
||||
bool propertySet(const std::string& _property, const std::string& _value);
|
||||
/**
|
||||
* @brief Get a specific value of the property reference name.
|
||||
* @param[in] property The property string name.
|
||||
* @return The value of the property (string).
|
||||
*/
|
||||
std::string propertyGet(const std::string& _property) const;
|
||||
/**
|
||||
* @brief Display all the property value with there name.
|
||||
* @param[in] changeOnly check at true if the user want to display only property that are not at default value.
|
||||
*/
|
||||
void propertyDisplay(bool _changeOnly = false) const;
|
||||
/**
|
||||
* @brief Get All the property configuration:
|
||||
* @return map on the propertys
|
||||
*/
|
||||
std::map<std::string, std::string> propertyGetAll(bool _notIfDefault=true) const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get count of propertys.
|
||||
* @return The number of the property.
|
||||
*/
|
||||
size_t getPropertyCount() const;
|
||||
/**
|
||||
* @brief Get name of a propertys.
|
||||
* @param[in] _id Id of the property.
|
||||
* @param[in] _name name of the property.
|
||||
* @return pointer on the property.
|
||||
*/
|
||||
eproperty::Property* getPropertyRaw(const size_t& _id) const;
|
||||
//! @previous
|
||||
eproperty::Property* getPropertyRaw(const std::string _name) const;
|
||||
eproperty::InterfaceData properties; //!< Interface to access at all properties...
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -9,20 +9,18 @@
|
||||
#include <eproperty/debug.h>
|
||||
#include <eproperty/List.h>
|
||||
#include <eproperty/Property.h>
|
||||
#include <eproperty/InterfaceData.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Interface"
|
||||
|
||||
eproperty::Interface::Interface() {
|
||||
eproperty::InterfaceData::InterfaceData() {
|
||||
|
||||
}
|
||||
|
||||
eproperty::Interface::~Interface() {
|
||||
propertyClean();
|
||||
eproperty::InterfaceData::~InterfaceData() {
|
||||
clean();
|
||||
}
|
||||
|
||||
// note this pointer is not allocated and not free at the end of the class
|
||||
void eproperty::Interface::propertyAdd(eproperty::Property* _pointerOnProperty) {
|
||||
void eproperty::InterfaceData::add(eproperty::Property* _pointerOnProperty) {
|
||||
if (_pointerOnProperty == nullptr) {
|
||||
EPROPERTY_ERROR("Try to link a nullptr properties");
|
||||
return;
|
||||
@@ -36,14 +34,14 @@ void eproperty::Interface::propertyAdd(eproperty::Property* _pointerOnProperty)
|
||||
m_list.push_back(_pointerOnProperty);
|
||||
}
|
||||
|
||||
void eproperty::Interface::propertyClean() {
|
||||
void eproperty::InterfaceData::clean() {
|
||||
// remove all pointer on these propertys
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
// Note no lock is needed at this level, because the lock is done is the upper elements ...
|
||||
// the property set might be done with a pool of property, allone, the overhed is bigger ...
|
||||
bool eproperty::Interface::propertySet(const std::string& _property, const std::string& _value) {
|
||||
bool eproperty::InterfaceData::set(const std::string& _property, const std::string& _value) {
|
||||
for (auto &it : m_list) {
|
||||
if( it != nullptr
|
||||
&& it->getName() == _property) {
|
||||
@@ -55,7 +53,7 @@ bool eproperty::Interface::propertySet(const std::string& _property, const std::
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string eproperty::Interface::propertyGet(const std::string& _property) const {
|
||||
std::string eproperty::InterfaceData::get(const std::string& _property) const {
|
||||
for (auto &it : m_list) {
|
||||
if( it != nullptr
|
||||
&& it->getName() == _property) {
|
||||
@@ -65,7 +63,7 @@ std::string eproperty::Interface::propertyGet(const std::string& _property) cons
|
||||
return "???";
|
||||
}
|
||||
|
||||
void eproperty::Interface::propertyDisplay(bool _changeOnly) const {
|
||||
void eproperty::InterfaceData::display(bool _changeOnly) const {
|
||||
EPROPERTY_INFO(" Object propertys:");
|
||||
for (auto &it : m_list) {
|
||||
if(it != nullptr) {
|
||||
@@ -82,7 +80,7 @@ void eproperty::Interface::propertyDisplay(bool _changeOnly) const {
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> eproperty::Interface::propertyGetAll(bool _notIfDefault) const {
|
||||
std::map<std::string, std::string> eproperty::InterfaceData::getAll(bool _notIfDefault) const {
|
||||
std::map<std::string, std::string> out;
|
||||
for (auto &it : m_list) {
|
||||
if(it != nullptr) {
|
||||
@@ -98,11 +96,11 @@ std::map<std::string, std::string> eproperty::Interface::propertyGetAll(bool _no
|
||||
}
|
||||
|
||||
|
||||
size_t eproperty::Interface::getPropertyCount() const {
|
||||
size_t eproperty::InterfaceData::size() const {
|
||||
return m_list.size();
|
||||
}
|
||||
|
||||
eproperty::Property* eproperty::Interface::getPropertyRaw(const size_t& _id) const {
|
||||
eproperty::Property* eproperty::InterfaceData::getRaw(const size_t& _id) const {
|
||||
if (_id >= m_list.size()) {
|
||||
EPROPERTY_ERROR("Wrong ID for property list. " << _id << " >= " << m_list.size());
|
||||
return nullptr;
|
||||
@@ -110,11 +108,12 @@ eproperty::Property* eproperty::Interface::getPropertyRaw(const size_t& _id) con
|
||||
return m_list[_id];
|
||||
}
|
||||
|
||||
eproperty::Property* eproperty::Interface::getPropertyRaw(const std::string _name) const {
|
||||
eproperty::Property* eproperty::InterfaceData::getRaw(const std::string _name) const {
|
||||
for (auto &it : m_list) {
|
||||
if(it->getName() == _name) {
|
||||
return it;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
87
eproperty/InterfaceData.h
Normal file
87
eproperty/InterfaceData.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace eproperty {
|
||||
class Property;
|
||||
class Ref;
|
||||
/**
|
||||
* @brief Interface data to collect the property list (for abstarction connection)
|
||||
*/
|
||||
class InterfaceData {
|
||||
private:
|
||||
std::vector<eproperty::Property*> m_list; //!< list of availlable Propertys (no need to free)
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor.
|
||||
*/
|
||||
InterfaceData();
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
virtual ~InterfaceData();
|
||||
/**
|
||||
* @brief Register a property class pointer in the List of propertys
|
||||
* @note This class does not destroy the property pointer!!!
|
||||
* @param[in] _pointerOnProperty Pointer on the property that might be added.
|
||||
*/
|
||||
void add(Property* _pointerOnProperty);
|
||||
/**
|
||||
* @brief Remove all the property reference in this class.
|
||||
* @note no delete, just clean and inform that a property has not been removed.
|
||||
*/
|
||||
void clean();
|
||||
/**
|
||||
* @brief Set a specific value to the property reference name.
|
||||
* @param[in] _property The property string name.
|
||||
* @param[in] _value The new value of the property (string).
|
||||
* @return true Property update.
|
||||
* @return false Property not update.
|
||||
*/
|
||||
bool set(const std::string& _property, const std::string& _value);
|
||||
/**
|
||||
* @brief Get a specific value of the property reference name.
|
||||
* @param[in] _property The property string name.
|
||||
* @return The value of the property (string).
|
||||
*/
|
||||
std::string get(const std::string& _property) const;
|
||||
/**
|
||||
* @brief Display all the property value with there name.
|
||||
* @param[in] _changeOnly check at true if the user want to display only property that are not at default value.
|
||||
*/
|
||||
void display(bool _changeOnly = false) const;
|
||||
/**
|
||||
* @brief Get All the property configuration:
|
||||
* @param[in] _notIfDefault if true the parameter value with default value are not extracted.
|
||||
* @return map on the propertys
|
||||
*/
|
||||
std::map<std::string, std::string> getAll(bool _notIfDefault=true) const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get count of propertys.
|
||||
* @return The number of the property.
|
||||
*/
|
||||
size_t size() const;
|
||||
/**
|
||||
* @brief Get name of a propertys.
|
||||
* @param[in] _id Id of the property.
|
||||
* @return pointer on the property.
|
||||
*/
|
||||
eproperty::Property* getRaw(const size_t& _id) const;
|
||||
/**
|
||||
* @brief Get name of a propertys.
|
||||
* @param[in] _name name of the property.
|
||||
* @return pointer on the property.
|
||||
*/
|
||||
eproperty::Property* getRaw(const std::string _name) const;
|
||||
};
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -11,16 +11,16 @@
|
||||
#include <map>
|
||||
#include <typeinfo>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "List<T>"
|
||||
|
||||
namespace eproperty {
|
||||
/**
|
||||
* @brief Set a list of value availlable (for enumeration)
|
||||
*/
|
||||
template<class TYPE> class List : public PropertyType<TYPE> {
|
||||
private:
|
||||
std::map<std::string, TYPE> m_list; //!< pointer on the list of all elements.
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with List of element parameter.
|
||||
* @brief Create a parameter with List of element parameter (nullptr if none).
|
||||
* @param[in] _owner reference on the parameter lister.
|
||||
* @param[in] _name Static name of the parameter.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
@@ -37,9 +37,23 @@ namespace eproperty {
|
||||
|
||||
};
|
||||
/**
|
||||
* @brief Destructor.
|
||||
* @brief Create a parameter with List of element parameter (nullptr if none).
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
*/
|
||||
List(const TYPE& _defaultValue) :
|
||||
eproperty::PropertyType<TYPE>(_defaultValue) {
|
||||
|
||||
};
|
||||
/**
|
||||
* @brief virtualisation of Destructor.
|
||||
*/
|
||||
virtual ~List() = default;
|
||||
/**
|
||||
* @brief Add a value in the list of parameter
|
||||
* @param[in] _value Value of the string
|
||||
* @param[in] _name String of the value
|
||||
* @param[in] _description Description of the parameter value
|
||||
*/
|
||||
void add(const TYPE& _value, const std::string& _name, const std::string& _description = "") {
|
||||
auto it = m_list.find(_name);
|
||||
if (it != m_list.end()) {
|
||||
@@ -48,6 +62,10 @@ namespace eproperty {
|
||||
}
|
||||
m_list.insert(std::make_pair(_name, _value));
|
||||
}
|
||||
/**
|
||||
* @brief Remove a value of the element availlable
|
||||
* @param[in] _name Name of the value to remove
|
||||
*/
|
||||
void remove(const std::string& _name) {
|
||||
auto it = m_list.find(_name);
|
||||
bool firstValue = false;
|
||||
@@ -75,6 +93,11 @@ namespace eproperty {
|
||||
eproperty::PropertyType<TYPE>::m_value = m_list.begin()->second;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Rename a value of the property
|
||||
* @param[in] _nameOld Old property name to replace
|
||||
* @param[in] _nameNew New name of the property
|
||||
*/
|
||||
void rename(const std::string& _nameOld, const std::string& _nameNew) {
|
||||
//get old value
|
||||
TYPE value;
|
||||
@@ -101,9 +124,11 @@ namespace eproperty {
|
||||
return;
|
||||
}
|
||||
EPROPERTY_WARNING("paramList value='" << _newVal << "' is not un the list ... ==> no change");
|
||||
for (auto &it : m_list) {
|
||||
EPROPERTY_VERBOSE(" element : " << it.first);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
for (auto &it : m_list) {
|
||||
EPROPERTY_VERBOSE(" element : " << it.first);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::string getInfo() const override {
|
||||
std::string list = "List default=" + getValueSpecific(eproperty::PropertyType<TYPE>::m_default) + " in : [";
|
||||
@@ -163,12 +188,10 @@ namespace eproperty {
|
||||
return "???";
|
||||
}
|
||||
};
|
||||
//! @not_in_doc
|
||||
template<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::List<TYPE>& _obj) {
|
||||
_os << _obj.get();
|
||||
return _os;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -17,10 +17,17 @@ eproperty::Property::Property(eproperty::Interface* _paramInterfaceLink, const s
|
||||
m_name(_name) {
|
||||
// add a reference on the current Property ...
|
||||
if (m_interfaceLink != nullptr) {
|
||||
m_interfaceLink->propertyAdd(this);
|
||||
m_interfaceLink->properties.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
eproperty::Property::Property() :
|
||||
m_interfaceLink(nullptr),
|
||||
m_setObserver(),
|
||||
m_name("") {
|
||||
|
||||
}
|
||||
|
||||
void eproperty::Property::setObserver(eproperty::Property::Observer _setObs) {
|
||||
m_setObserver = _setObs;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -12,19 +12,42 @@
|
||||
#include <typeinfo>
|
||||
#include <functional>
|
||||
|
||||
/**
|
||||
* @brief eproperty global interface for all property implementation
|
||||
*/
|
||||
namespace eproperty {
|
||||
class Ref;
|
||||
/**
|
||||
* @brief Base of the property With all generic element needed
|
||||
*/
|
||||
class Property {
|
||||
public:
|
||||
using Observer = std::function<void()>;
|
||||
using Observer = std::function<void()>; //!< Local main object observer of changing value of the property
|
||||
private:
|
||||
eproperty::Interface* m_interfaceLink;
|
||||
Observer m_setObserver;
|
||||
std::string m_name;
|
||||
eproperty::Interface* m_interfaceLink; //!< Base interface class to group all the property
|
||||
Observer m_setObserver; //!< Observer of the changing value
|
||||
std::string m_name; //!< Name of the property
|
||||
public:
|
||||
/**
|
||||
* @brief Basic property elements
|
||||
* @param[in] _paramInterfaceLink Link on the esignal::Interface class to register parameter (can be nullptr)
|
||||
* @param[in] _name Name of the parameter (must be unique if _paramInterfaceLink is define)
|
||||
*/
|
||||
Property(eproperty::Interface* _paramInterfaceLink, const std::string& _name);
|
||||
/**
|
||||
* @brief Basic property elements
|
||||
*/
|
||||
Property();
|
||||
/**
|
||||
* @brief Virtualize the destructor
|
||||
* @internal
|
||||
*/
|
||||
virtual ~Property() = default;
|
||||
protected:
|
||||
/**
|
||||
* @brief Set the change observer of the property
|
||||
* @param[in] _setObs New observer of the property
|
||||
*/
|
||||
void setObserver(eproperty::Property::Observer _setObs);
|
||||
public:
|
||||
/**
|
||||
@@ -83,16 +106,52 @@ namespace eproperty {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Eguality comparaison operator (REMOVED)
|
||||
* @param[in] _obj Object to compare
|
||||
* @return true The current object is identic
|
||||
* @return false The current object is NOT identic
|
||||
*/
|
||||
template<class TYPE>
|
||||
bool operator== (const TYPE& _obj) const = delete;
|
||||
/**
|
||||
* @brief IN-Eguality comparaison operator (REMOVED)
|
||||
* @param[in] _obj Object to compare
|
||||
* @return true The current object is NOT identic
|
||||
* @return false The current object is identic
|
||||
*/
|
||||
template<class TYPE>
|
||||
bool operator!= (const TYPE& _obj) const = delete;
|
||||
/**
|
||||
* @brief Lesser eguality comparaison operator (REMOVED)
|
||||
* @param[in] _obj Object to compare
|
||||
* @return true The current object lesser or equal than input object
|
||||
* @return false The current object greater than input object
|
||||
*/
|
||||
template<class TYPE>
|
||||
bool operator<= (const TYPE& _obj) const = delete;
|
||||
/**
|
||||
* @brief Greater eguality comparaison operator (REMOVED)
|
||||
* @param[in] _obj Object to compare
|
||||
* @return true The current object greater or equal than input object
|
||||
* @return false The current object lesser than input object
|
||||
*/
|
||||
template<class TYPE>
|
||||
bool operator>= (const TYPE& _obj) const = delete;
|
||||
/**
|
||||
* @brief Lesser comparaison operator (REMOVED)
|
||||
* @param[in] _obj Object to compare
|
||||
* @return true The current object lesser than input object
|
||||
* @return false The current object greater or equal than input object
|
||||
*/
|
||||
template<class TYPE>
|
||||
bool operator< (const TYPE& _obj) const = delete;
|
||||
/**
|
||||
* @brief Greater comparaison operator (REMOVED)
|
||||
* @param[in] _obj Object to compare
|
||||
* @return true The current object greater than input object
|
||||
* @return false The current object lesser or equal than input object
|
||||
*/
|
||||
template<class TYPE>
|
||||
bool operator> (const TYPE& _obj) const = delete;
|
||||
};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -11,10 +11,10 @@
|
||||
#include <eproperty/Property.h>
|
||||
#include <eproperty/debug.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "PropertyType<T>"
|
||||
|
||||
namespace eproperty {
|
||||
/**
|
||||
* @brief Template base of the property (have a generic set and get for string)
|
||||
*/
|
||||
template<class TYPE> class PropertyType : public Property {
|
||||
protected:
|
||||
TYPE m_value; //!< Current value.
|
||||
@@ -22,7 +22,7 @@ namespace eproperty {
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _owner Owner of the parameter.
|
||||
* @param[in] _owner Owner of the parameter (nullptr if none).
|
||||
* @param[in] _name Static name of the parameter.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
* @param[in] _description description of the parameter.
|
||||
@@ -41,6 +41,15 @@ namespace eproperty {
|
||||
setObserver([=](){(*_owner.*_setObs)();});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
*/
|
||||
PropertyType(const TYPE& _defaultValue) :
|
||||
m_value(_defaultValue),
|
||||
m_default(_defaultValue) {
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
@@ -66,6 +75,10 @@ namespace eproperty {
|
||||
void setDefault() override {
|
||||
set(m_default);
|
||||
}
|
||||
/**
|
||||
* @brief Set new default value on the property
|
||||
* @param[in] _newDefault New value to set
|
||||
*/
|
||||
virtual void changeDefault(const TYPE& _newDefault) {
|
||||
m_default = _newDefault;
|
||||
}
|
||||
@@ -80,7 +93,7 @@ namespace eproperty {
|
||||
};
|
||||
/**
|
||||
* @brief Set a new value for this parameter
|
||||
* @param[in] newVal New value to set (set the nearest value if range is set)
|
||||
* @param[in] _newVal New value to set (set the nearest value if range is set)
|
||||
*/
|
||||
virtual void set(const TYPE& _newVal) {
|
||||
if (_newVal != m_value) {
|
||||
@@ -93,11 +106,16 @@ namespace eproperty {
|
||||
* @note For performence, this function must be inline
|
||||
* @note Only use by the owner of the property (can not be check on compile time for now ...)
|
||||
* TODO: Do it better ... compile check
|
||||
* @param[in] newVal New value to set
|
||||
* @param[in] _newVal New value to set
|
||||
*/
|
||||
inline void setDirect(const TYPE& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
/**
|
||||
* @brief Set the value of the current parameter (check range and ... if needed).
|
||||
* @note Only use by the owner of the property/
|
||||
* @param[in] _newVal New value to set
|
||||
*/
|
||||
virtual void setDirectCheck(const TYPE& _newVal) {
|
||||
m_value = _newVal;
|
||||
}
|
||||
@@ -111,25 +129,44 @@ namespace eproperty {
|
||||
TYPE& getDirect() {
|
||||
return m_value;
|
||||
}
|
||||
/**
|
||||
* @brief Get the string of the specify value.
|
||||
* @param[in] _valueRequested Value to convert in string
|
||||
* @return convertion of the value in string.
|
||||
*/
|
||||
virtual std::string getValueSpecific(const TYPE& _valueRequested) const = 0;
|
||||
public:
|
||||
/**
|
||||
* @brief Const cast the property in the Type of the data
|
||||
* @return Const reference on the value.
|
||||
*/
|
||||
operator const TYPE&() const {
|
||||
return m_value;
|
||||
}
|
||||
/**
|
||||
* @brief Get the property Value
|
||||
* @return Const reference on the value.
|
||||
*/
|
||||
const TYPE& operator *() const noexcept {
|
||||
return m_value;
|
||||
}
|
||||
/**
|
||||
* @brief Get the property Value
|
||||
* @return Const reference on the value.
|
||||
*/
|
||||
const TYPE* operator->() const noexcept {
|
||||
return &m_value;
|
||||
}
|
||||
const PropertyType<TYPE>& operator= (const TYPE& _newVal) = delete;
|
||||
/**
|
||||
* @brief Assignation opérator (REMOVED)
|
||||
* @param _newVal Value to asign
|
||||
* @return Reference on current object
|
||||
*/
|
||||
PropertyType<TYPE>& operator= (const TYPE& _newVal) = delete;
|
||||
};
|
||||
|
||||
//! @not_in_doc
|
||||
template<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::PropertyType<TYPE>& _obj) {
|
||||
_os << _obj.get();
|
||||
return _os;
|
||||
}
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -11,10 +11,11 @@
|
||||
#include <eproperty/Value.h>
|
||||
#include <typeinfo>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Range<T>"
|
||||
|
||||
namespace eproperty {
|
||||
/**
|
||||
* @brief Range template of the property (limit with a min and a max value)
|
||||
* @tparam TYPE Tpe of the range value
|
||||
*/
|
||||
template<class TYPE> class Range : public Value<TYPE> {
|
||||
private:
|
||||
TYPE m_min; //!< Minimum value.
|
||||
@@ -22,7 +23,7 @@ namespace eproperty {
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _owner reference on the parameter lister.
|
||||
* @param[in] _owner reference on the parameter lister (nullptr if none).
|
||||
* @param[in] _name Static name of the parameter.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
* @param[in] _min Minumum value.
|
||||
@@ -45,6 +46,15 @@ namespace eproperty {
|
||||
//EPROPERTY_CRITICAL("min > max...");
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
* @param[in] _min Minumum value.
|
||||
* @param[in] _max Maximum value.
|
||||
*/
|
||||
Range(const TYPE& _defaultValue,
|
||||
const TYPE& _min,
|
||||
const TYPE& _max);
|
||||
/**
|
||||
* @brief Destructor.
|
||||
*/
|
||||
@@ -56,13 +66,9 @@ namespace eproperty {
|
||||
void set(const TYPE& _newVal) override;
|
||||
void setDirectCheck(const TYPE& _newVal) override;
|
||||
};
|
||||
|
||||
//! @not_in_doc
|
||||
template<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::Range<TYPE>& _obj) {
|
||||
_os << _obj.get();
|
||||
return _os;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -13,15 +13,15 @@
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/Color.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Value<T>"
|
||||
|
||||
namespace eproperty {
|
||||
/**
|
||||
* @brief Simple Value of the property (need to implement fuction etk::from_string<TYPE> to use it)
|
||||
*/
|
||||
template<class TYPE> class Value : public PropertyType<TYPE> {
|
||||
public:
|
||||
/**
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _owner Owner of the parameter.
|
||||
* @param[in] _owner Owner of the parameter (nullptr if none).
|
||||
* @param[in] _name Static name of the parameter.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
* @param[in] _description description of the parameter.
|
||||
@@ -36,22 +36,19 @@ namespace eproperty {
|
||||
eproperty::PropertyType<TYPE>(_owner, _name, _defaultValue, _description, _setObs) {
|
||||
|
||||
}
|
||||
protected:
|
||||
/**
|
||||
* @brief Get the string of the specify value.
|
||||
* @return convetion of the velue in string.
|
||||
* @brief Create a parameter with a specific type.
|
||||
* @param[in] _defaultValue Default value of the parameter.
|
||||
*/
|
||||
Value(const TYPE& _defaultValue);
|
||||
public:
|
||||
std::string getValueSpecific(const TYPE& _valueRequested) const override;
|
||||
void setString(const std::string& _newVal) override;
|
||||
};
|
||||
|
||||
//! @not_in_doc
|
||||
template<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::Value<TYPE>& _obj) {
|
||||
_os << _obj.get();
|
||||
return _os;
|
||||
}
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -11,8 +11,6 @@
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/Color.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Range<T>"
|
||||
// void generic properties
|
||||
template class eproperty::Range<int64_t>;
|
||||
template class eproperty::Range<int32_t>;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -9,8 +9,18 @@
|
||||
|
||||
#include <eproperty/Range.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Range<T>"
|
||||
|
||||
template<class TYPE>
|
||||
eproperty::Range<TYPE>::Range(const TYPE& _defaultValue,
|
||||
const TYPE& _min,
|
||||
const TYPE& _max) :
|
||||
eproperty::Value<TYPE>(_defaultValue),
|
||||
m_min(_min),
|
||||
m_max(_max) {
|
||||
if (m_min > m_max) {
|
||||
//EPROPERTY_CRITICAL("min > max...");
|
||||
}
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
std::string eproperty::Range<TYPE>::getPropertyType() const {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -12,8 +12,6 @@
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/Color.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Value<T>"
|
||||
// void generic properties
|
||||
template class eproperty::Value<bool>;
|
||||
template class eproperty::Value<std::string>;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
@@ -9,8 +9,12 @@
|
||||
|
||||
#include <eproperty/Value.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Value<T>"
|
||||
|
||||
template<class TYPE>
|
||||
eproperty::Value<TYPE>::Value(const TYPE& _defaultValue) :
|
||||
eproperty::PropertyType<TYPE>(_defaultValue) {
|
||||
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
std::string eproperty::Value<TYPE>::getValueSpecific(const TYPE& _valueRequested) const {
|
||||
@@ -24,8 +28,3 @@ void eproperty::Value<TYPE>::setString(const std::string& _newVal) {
|
||||
// TODO : Do it better ...
|
||||
eproperty::PropertyType<TYPE>::notifyChange();
|
||||
}
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ nullptr
|
||||
|
||||
|
34
lutin_eproperty-sample.py
Normal file
34
lutin_eproperty-sample.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.module as module
|
||||
import lutin.tools as tools
|
||||
import datetime
|
||||
|
||||
def get_type():
|
||||
return "BINARY"
|
||||
|
||||
def get_sub_type():
|
||||
return "SAMPLE"
|
||||
|
||||
def get_desc():
|
||||
return "e-property sample 1"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return "authors.txt"
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_src_file([
|
||||
'sample/sampleAll.cpp'
|
||||
])
|
||||
my_module.add_depend(['eproperty', 'test-debug'])
|
||||
return my_module
|
||||
|
@@ -23,7 +23,7 @@ def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
return "authors.txt"
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
@@ -34,6 +34,6 @@ def create(target, module_name):
|
||||
'test/test_range.cpp',
|
||||
'test/test_value.cpp'
|
||||
])
|
||||
my_module.add_module_depend(['eproperty', 'gtest', 'test-debug'])
|
||||
my_module.add_depend(['eproperty', 'gtest', 'test-debug'])
|
||||
return my_module
|
||||
|
||||
|
@@ -21,18 +21,18 @@ def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
return "authors.txt"
|
||||
|
||||
def get_version():
|
||||
return [0,1,"dev"]
|
||||
return "version.txt"
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
my_module.add_extra_compile_flags()
|
||||
my_module.add_extra_flags()
|
||||
my_module.add_src_file([
|
||||
'eproperty/debug.cpp',
|
||||
'eproperty/Property.cpp',
|
||||
'eproperty/Interface.cpp',
|
||||
'eproperty/InterfaceData.cpp',
|
||||
'eproperty/details/Range.cpp',
|
||||
'eproperty/details/Value.cpp',
|
||||
])
|
||||
@@ -40,6 +40,7 @@ def create(target, module_name):
|
||||
'eproperty/debug.h',
|
||||
'eproperty/Value.h',
|
||||
'eproperty/Interface.h',
|
||||
'eproperty/InterfaceData.h',
|
||||
'eproperty/Property.h',
|
||||
'eproperty/PropertyType.h',
|
||||
'eproperty/Range.h',
|
||||
@@ -47,9 +48,9 @@ def create(target, module_name):
|
||||
'eproperty/details/Range.hxx',
|
||||
'eproperty/details/Value.hxx',
|
||||
])
|
||||
my_module.add_module_depend(['etk'])
|
||||
my_module.add_depend(['etk'])
|
||||
my_module.add_path(tools.get_current_path(__file__))
|
||||
my_module.compile_flags('c++', [
|
||||
my_module.add_flag('c++', [
|
||||
"-DEPROPERTY_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\""
|
||||
])
|
||||
return my_module
|
||||
|
19
monk_eproperty.py
Normal file
19
monk_eproperty.py
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
import monkModule
|
||||
import monkTools as tools
|
||||
import os
|
||||
|
||||
def get_desc():
|
||||
return "E-property simple property interface"
|
||||
|
||||
def create():
|
||||
# module name is 'ewol' and type binary.
|
||||
myModule = monkModule.Module(__file__, 'eproperty', 'LIBRARY')
|
||||
# enable doculentation :
|
||||
myModule.set_website("http://atria-soft.github.io/eproperty/")
|
||||
myModule.set_website_sources("http://github.com/atria-soft/eproperty/")
|
||||
myModule.set_path(os.path.join(tools.get_current_path(__file__), "eproperty"))
|
||||
myModule.set_path_general_doc(os.path.join(tools.get_current_path(__file__), "doc"))
|
||||
# add the currrent module at the
|
||||
return myModule
|
||||
|
163
sample/sampleAll.cpp
Normal file
163
sample/sampleAll.cpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2016, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#include <etk/etk.h>
|
||||
#include <test-debug/debug.h>
|
||||
|
||||
//! [eproperty_sample_all]
|
||||
|
||||
//! [eproperty_sample_declare_interface]
|
||||
#include <eproperty/Interface.h>
|
||||
//! [eproperty_sample_declare_interface]
|
||||
//! [eproperty_sample_declare_value]
|
||||
#include <eproperty/Value.h>
|
||||
//! [eproperty_sample_declare_value]
|
||||
//! [eproperty_sample_declare_list]
|
||||
#include <eproperty/List.h>
|
||||
//! [eproperty_sample_declare_list]
|
||||
//! [eproperty_sample_declare_range]
|
||||
#include <eproperty/Range.h>
|
||||
//! [eproperty_sample_declare_range]
|
||||
|
||||
//! [eproperty_sample_declare_an_enum]
|
||||
enum simpleEnum {
|
||||
simpleEnum_enum1,
|
||||
simpleEnum_enum2,
|
||||
simpleEnum_enum3,
|
||||
simpleEnum_enum4,
|
||||
};
|
||||
//! [eproperty_sample_declare_an_enum]
|
||||
|
||||
//! [eproperty_sample_class_with_interface]
|
||||
//! [eproperty_sample_declare_class_with_interface]
|
||||
class sampleClassGroup : public eproperty::Interface {
|
||||
//! [eproperty_sample_declare_class_with_interface]
|
||||
public:
|
||||
//! [eproperty_sample_declare_class_property_value]
|
||||
eproperty::Value<std::string> propertyValue; //!< Simple property Value with type string
|
||||
//! [eproperty_sample_declare_class_property_value]
|
||||
//! [eproperty_sample_declare_class_property_list]
|
||||
eproperty::List<enum simpleEnum> propertyList; //!< Simple property List with type enumeration
|
||||
//! [eproperty_sample_declare_class_property_list]
|
||||
//! [eproperty_sample_declare_class_property_range]
|
||||
eproperty::Range<int32_t> propertyRange; //!< Simple property Range with type integer
|
||||
//! [eproperty_sample_declare_class_property_range]
|
||||
|
||||
sampleClassGroup():
|
||||
//! [eproperty_sample_initialize_class_property_value]
|
||||
propertyValue(this, "value", "default value", "optionnal Description", &sampleClassGroup::onPropertyChangeValue),
|
||||
//! [eproperty_sample_initialize_class_property_value]
|
||||
//! [eproperty_sample_initialize_class_property_list]
|
||||
propertyList(this, "list", simpleEnum_enum4),
|
||||
//! [eproperty_sample_initialize_class_property_list]
|
||||
//! [eproperty_sample_initialize_class_property_range]
|
||||
propertyRange(this, "range", 5646546, -5, 555555555) {
|
||||
//! [eproperty_sample_initialize_class_property_range]
|
||||
// add all enumeration values
|
||||
//! [eproperty_sample_initialize_class_property_list_add]
|
||||
propertyList.add(simpleEnum_enum1, "enum1");
|
||||
propertyList.add(simpleEnum_enum2, "enum2");
|
||||
propertyList.add(simpleEnum_enum3, "enum3");
|
||||
propertyList.add(simpleEnum_enum4, "enum4");
|
||||
//! [eproperty_sample_initialize_class_property_list_add]
|
||||
//! [eproperty_sample_initialize_class_property_list_rename]
|
||||
// Rename an element
|
||||
propertyList.rename("enum1", "new enum name");
|
||||
// Remove an element
|
||||
propertyList.remove("enum2");
|
||||
//! [eproperty_sample_initialize_class_property_list_rename]
|
||||
//! [eproperty_sample_initialize_class_property_set_direct]
|
||||
// no check on the value set (the faster in CPU cycle)
|
||||
propertyValue.setDirect("New Value to Set");
|
||||
// Check the internal value (better for range)
|
||||
propertyRange.setDirectCheck(-5555);
|
||||
//! [eproperty_sample_initialize_class_property_set_direct]
|
||||
}
|
||||
//! [eproperty_sample_initialize_class_property_value_callback]
|
||||
void onPropertyChangeValue() {
|
||||
TEST_PRINT("Property value has change ... " << *propertyValue);
|
||||
|
||||
TEST_INFO("Use properties:");
|
||||
//! [eproperty_sample_get_value_value]
|
||||
TEST_INFO(" value:" << *propertyValue);
|
||||
//! [eproperty_sample_get_value_value]
|
||||
//! [eproperty_sample_get_value_range]
|
||||
TEST_INFO(" range:" << *propertyRange);
|
||||
//! [eproperty_sample_get_value_range]
|
||||
//! [eproperty_sample_get_value_list]
|
||||
TEST_INFO(" list:" << *propertyList);
|
||||
//! [eproperty_sample_get_value_list]
|
||||
|
||||
|
||||
}
|
||||
//! [eproperty_sample_initialize_class_property_value_callback]
|
||||
};
|
||||
//! [eproperty_sample_class_with_interface]
|
||||
|
||||
//! [eproperty_sample_class_without_interface]
|
||||
class sampleClassSolo {
|
||||
public:
|
||||
eproperty::Value<std::string> propertyValue;
|
||||
eproperty::List<enum simpleEnum> propertyList;
|
||||
eproperty::Range<int32_t> propertyRange;
|
||||
sampleClassSolo():
|
||||
//! [eproperty_sample_initialize_class_property_value2]
|
||||
propertyValue("default value"),
|
||||
//! [eproperty_sample_initialize_class_property_value2]
|
||||
//! [eproperty_sample_initialize_class_property_list2]
|
||||
propertyList(simpleEnum_enum4),
|
||||
//! [eproperty_sample_initialize_class_property_list2]
|
||||
//! [eproperty_sample_initialize_class_property_range2]
|
||||
propertyRange(5646546, -5, 555555555) {
|
||||
//! [eproperty_sample_initialize_class_property_range2]
|
||||
propertyList.add(simpleEnum_enum1, "enum1");
|
||||
propertyList.add(simpleEnum_enum2, "enum2");
|
||||
propertyList.add(simpleEnum_enum3, "enum3");
|
||||
propertyList.add(simpleEnum_enum4, "enum4");
|
||||
}
|
||||
};
|
||||
//! [eproperty_sample_class_without_interface]
|
||||
|
||||
void simpleSet() {
|
||||
//! [eproperty_sample_use_declare_class]
|
||||
sampleClassGroup myClass;
|
||||
//! [eproperty_sample_use_declare_class]
|
||||
|
||||
//! [eproperty_sample_use_set_value_1]
|
||||
myClass.propertyValue.set("New Value");
|
||||
myClass.propertyValue.setString("New Value 2");
|
||||
//! [eproperty_sample_use_set_value_1]
|
||||
//! [eproperty_sample_use_set_list_1]
|
||||
myClass.propertyList.set(simpleEnum_enum3);
|
||||
myClass.propertyList.setString("enum3");
|
||||
//! [eproperty_sample_use_set_list_1]
|
||||
//! [eproperty_sample_use_set_range_1]
|
||||
myClass.propertyRange.set(15621);
|
||||
myClass.propertyRange.setString("15621");
|
||||
//! [eproperty_sample_use_set_range_1]
|
||||
|
||||
//! [eproperty_sample_use_set_value_2]
|
||||
myClass.properties.set("value", "New Value in string");
|
||||
//! [eproperty_sample_use_set_value_2]
|
||||
//! [eproperty_sample_use_set_list_2]
|
||||
myClass.properties.set("list", "enum4");
|
||||
//! [eproperty_sample_use_set_list_2]
|
||||
//! [eproperty_sample_use_set_range_2]
|
||||
myClass.properties.set("range", "-2");
|
||||
//! [eproperty_sample_use_set_range_2]
|
||||
|
||||
}
|
||||
//! [eproperty_sample_all]
|
||||
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
TEST_INFO("simpleSet [START] ***************************");
|
||||
simpleSet();
|
||||
TEST_INFO("simpleSet [STOP] ***************************");
|
||||
return 0;
|
||||
}
|
@@ -12,9 +12,6 @@
|
||||
#include <test-debug/debug.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "eproperty-test"
|
||||
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
::testing::InitGoogleTest(&_argc, const_cast<char **>(_argv));
|
||||
etk::init(_argc, _argv);
|
||||
|
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.3.0
|
Reference in New Issue
Block a user