mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 21:18:32 -05:00
More Property work
Cleaning up Property classes Added property owner
This commit is contained in:
@@ -33,76 +33,23 @@ namespace properties {
|
||||
template <typename T>
|
||||
class NumericalProperty : public TemplateProperty<T> {
|
||||
public:
|
||||
NumericalProperty(const std::string& identifier, const std::string& guiName);
|
||||
NumericalProperty(std::string identifier, std::string guiName);
|
||||
NumericalProperty(std::string identifier, std::string guiName, T value);
|
||||
NumericalProperty(std::string identifier, std::string guiName, T value,
|
||||
T minimumValue, T maximumValue);
|
||||
|
||||
NumericalProperty(const std::string& identifier, const std::string& guiName,
|
||||
const T& value);
|
||||
|
||||
NumericalProperty(const std::string& identifier, const std::string& guiName,
|
||||
const T& value, const T& minimumValue);
|
||||
|
||||
NumericalProperty(const std::string& identifier, const std::string& guiName,
|
||||
const T& value, const T& minimumValue, const T& maximumValue);
|
||||
|
||||
NumericalProperty(const std::string& identifier, const std::string& guiName,
|
||||
const T& value, const T& minimumValue, const T& maximumValue,
|
||||
const T& stepping);
|
||||
|
||||
virtual std::string className() const;
|
||||
virtual std::string className() const override;
|
||||
|
||||
using TemplateProperty<T>::operator=;
|
||||
|
||||
protected:
|
||||
T _minimumValue;
|
||||
T _maximumValue;
|
||||
T _stepping;
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
// use inside namespace (?)
|
||||
#define REGISTER_NUMERICALPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef NumericalProperty<TYPE> CLASS_NAME; \
|
||||
template <> std::string PropertyDelegate<NumericalProperty<TYPE>>::className(); \
|
||||
template <> std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultStepping<TYPE>();
|
||||
|
||||
|
||||
#define REGISTER_NUMERICALPROPERTY_SOURCE(CLASS_NAME, TYPE, \
|
||||
DEFAULT_VALUE, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, DEFAULT_STEPPING) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() { \
|
||||
return DEFAULT_VALUE; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() { \
|
||||
return DEFAULT_MIN_VALUE; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() { \
|
||||
return DEFAULT_MAX_VALUE; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultStepping<TYPE>() { \
|
||||
return DEFAULT_STEPPING; \
|
||||
}
|
||||
|
||||
#include "openspace/properties/numericalproperty.inl"
|
||||
|
||||
#endif // __NUMERICALPROPERTY_H__
|
||||
|
||||
@@ -25,58 +25,71 @@
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
// Delegating constructors seem to be necessary; Visual Studio 2013 compiler could not
|
||||
#define REGISTER_NUMERICALPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef NumericalProperty<TYPE> CLASS_NAME; \
|
||||
template <> std::string PropertyDelegate<NumericalProperty<TYPE>>::className(); \
|
||||
template <> std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>();
|
||||
|
||||
|
||||
#define REGISTER_NUMERICALPROPERTY_SOURCE(CLASS_NAME, TYPE, \
|
||||
DEFAULT_VALUE, DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, DEFAULT_STEPPING) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() { \
|
||||
return DEFAULT_VALUE; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() { \
|
||||
return DEFAULT_MIN_VALUE; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() { \
|
||||
return DEFAULT_MAX_VALUE; \
|
||||
}
|
||||
|
||||
// Delegating constructors are necessary; automatic template deduction cannot
|
||||
// deduce template argument for 'U' if 'default' methods are used as default values in
|
||||
// a single constructor
|
||||
|
||||
template <typename T>
|
||||
NumericalProperty<T>::NumericalProperty(const std::string& identifier,
|
||||
const std::string& guiName)
|
||||
: NumericalProperty<T>(identifier, guiName,
|
||||
NumericalProperty<T>::NumericalProperty(std::string identifier, std::string guiName)
|
||||
: NumericalProperty<T>(std::move(identifier), std::move(guiName),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>(),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultStepping<T>())
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>())
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
NumericalProperty<T>::NumericalProperty(const std::string& identifier,
|
||||
const std::string& guiName, const T& value)
|
||||
: NumericalProperty<T>(identifier, guiName, value,
|
||||
NumericalProperty<T>::NumericalProperty(std::string identifier,
|
||||
std::string guiName, T value)
|
||||
: NumericalProperty<T>(std::move(identifier), std::move(guiName), std::move(value),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>())
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>())
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
NumericalProperty<T>::NumericalProperty(const std::string& identifier,
|
||||
const std::string& guiName, const T& value,
|
||||
const T& minimumValue)
|
||||
: NumericalProperty<T>(identifier, guiName, value, minimumValue,
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>())
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
NumericalProperty<T>::NumericalProperty(const std::string& identifier,
|
||||
const std::string& guiName, const T& value,
|
||||
const T& minimumValue, const T& maximumValue)
|
||||
: NumericalProperty<T>(identifier, guiName, value, minimumValue, maximumValue,
|
||||
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>())
|
||||
NumericalProperty<T>::NumericalProperty(std::string identifier,
|
||||
std::string guiName, T value,
|
||||
T minimumValue, T maximumValue)
|
||||
: TemplateProperty<T>(std::move(identifier), std::move(guiName), std::move(value))
|
||||
, _minimumValue(std::move(minimumValue))
|
||||
, _maximumValue(std::move(maximumValue))
|
||||
{}
|
||||
|
||||
|
||||
template <typename T>
|
||||
NumericalProperty<T>::NumericalProperty(const std::string& identifier,
|
||||
const std::string& guiName, const T& value,
|
||||
const T& minimumValue, const T& maximumValue,
|
||||
const T& stepping)
|
||||
: TemplateProperty<T>(identifier, guiName, value)
|
||||
, _minimumValue(minimumValue)
|
||||
, _maximumValue(maximumValue)
|
||||
, _stepping(stepping)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
std::string NumericalProperty<T>::className() const {
|
||||
return PropertyDelegate<NumericalProperty<T>>::className();
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "openspace/properties/propertydelegate.h"
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <boost/any.hpp>
|
||||
#include <string>
|
||||
|
||||
@@ -35,21 +36,21 @@ namespace properties {
|
||||
|
||||
class Property {
|
||||
public:
|
||||
Property(const std::string& identifier, const std::string& guiName);
|
||||
Property(std::string identifier, std::string guiName);
|
||||
virtual ~Property();
|
||||
|
||||
//virtual Property* create() const = 0;
|
||||
virtual std::string className() const = 0;
|
||||
|
||||
virtual boost::any get() const;
|
||||
virtual void set(const boost::any& value);
|
||||
virtual void set(boost::any value);
|
||||
virtual const std::type_info& type() const;
|
||||
|
||||
const std::string& identifier() const;
|
||||
const std::string& guiName() const;
|
||||
|
||||
void setGroupIdentifier(const std::string& groupId);
|
||||
const std::string& groupIdentifier() const;
|
||||
void setGroupIdentifier(std::string groupId);
|
||||
std::string groupIdentifier() const;
|
||||
|
||||
void setVisible(bool state);
|
||||
bool isVisible() const;
|
||||
@@ -57,13 +58,20 @@ public:
|
||||
void setReadOnly(bool state);
|
||||
bool isReadOnly() const;
|
||||
|
||||
void setViewOption(std::string option, bool value = true);
|
||||
bool viewOption(const std::string& option) const;
|
||||
|
||||
struct ViewOptions {
|
||||
static const std::string LightPosition;
|
||||
static const std::string Color;
|
||||
};
|
||||
|
||||
const ghoul::Dictionary& metaData() const;
|
||||
|
||||
protected:
|
||||
std::string _identifier;
|
||||
std::string _guiName;
|
||||
std::string _groupId;
|
||||
|
||||
bool _isVisible;
|
||||
bool _isReadOnly;
|
||||
ghoul::Dictionary _metaData;
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
@@ -43,9 +43,6 @@ public:
|
||||
|
||||
template <typename U>
|
||||
static U defaultMaximumValue();
|
||||
|
||||
template <typename U>
|
||||
static U defaultStepping();
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
|
||||
@@ -31,39 +31,29 @@ namespace properties {
|
||||
|
||||
template <typename T>
|
||||
std::string PropertyDelegate<T>::className() {
|
||||
// static_assert(false, "Unimplemented PropertyDelegate::className specialization");
|
||||
static_assert(false, "Unimplemented PropertyDelegate::className specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::defaultValue() {
|
||||
// static_assert(false, "Unimplemented PropertyDelegate::defaultValue specialization");
|
||||
static_assert(false, "Unimplemented PropertyDelegate::defaultValue specialization");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::defaultMinimumValue() {
|
||||
// static_assert(false,
|
||||
// "Unimplemented PropertyDelegate::defaultMinimumValue specialization");
|
||||
static_assert(false,
|
||||
"Unimplemented PropertyDelegate::defaultMinimumValue specialization");
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::defaultMaximumValue() {
|
||||
// static_assert(false,
|
||||
// "Unimplemented PropertyDelegate::defaultMaximumValue specialization");
|
||||
static_assert(false,
|
||||
"Unimplemented PropertyDelegate::defaultMaximumValue specialization");
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
U PropertyDelegate<T>::defaultStepping() {
|
||||
// static_assert(false,
|
||||
// "Unimplemented PropertyDelegate::defaultStepping specialization");
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
} // namespace openspace
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __PROPERTYOWNER_H__
|
||||
#define __PROPERTYOWNER_H__
|
||||
|
||||
#include <openspace/properties/property.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
class PropertyOwner {
|
||||
public:
|
||||
virtual ~PropertyOwner();
|
||||
|
||||
virtual const std::string& name() const = 0;
|
||||
const std::vector<Property*>& properties() const;
|
||||
Property* property(const std::string& id) const;
|
||||
|
||||
void setPropertyGroupName(std::string groupID, std::string name);
|
||||
const std::string& propertyGroupName(const std::string& groupID) const;
|
||||
|
||||
protected:
|
||||
void addProperty(Property* prop);
|
||||
void addProperty(Property& prop);
|
||||
|
||||
void removeProperty(Property* prop);
|
||||
void removeProperty(Property& prop);
|
||||
|
||||
private:
|
||||
std::vector<Property*> _properties;
|
||||
std::map<std::string, std::string> _groupNames;
|
||||
};
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __PROPERTYOWNER_H__
|
||||
@@ -31,10 +31,7 @@ namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
REGISTER_TEMPLATEPROPERTY_HEADER(BoolProperty, bool);
|
||||
|
||||
REGISTER_NUMERICALPROPERTY_HEADER(CharProperty, char);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(Char16Property, char16_t);
|
||||
//REGISTER_NUMERICALPROPERTY_HEADER(Char32Property, char32_t);
|
||||
REGISTER_NUMERICALPROPERTY_HEADER(WCharProperty, wchar_t);
|
||||
REGISTER_NUMERICALPROPERTY_HEADER(SignedCharProperty, signed char);
|
||||
REGISTER_NUMERICALPROPERTY_HEADER(UCharProperty, unsigned char);
|
||||
|
||||
@@ -33,12 +33,13 @@ namespace properties {
|
||||
template <typename T>
|
||||
class TemplateProperty : public Property {
|
||||
public:
|
||||
TemplateProperty(const std::string& identifier, const std::string& guiName);
|
||||
TemplateProperty(std::string identifier, std::string guiName);
|
||||
TemplateProperty(std::string identifier, std::string guiName, T value);
|
||||
|
||||
TemplateProperty(const std::string& identifier, const std::string& guiName,
|
||||
const T& value);
|
||||
|
||||
virtual std::string className() const;
|
||||
virtual std::string className() const override;
|
||||
virtual boost::any get() const override;
|
||||
virtual void set(boost::any value) override;
|
||||
virtual const std::type_info& type() const override;
|
||||
|
||||
operator T();
|
||||
TemplateProperty<T>& operator=(T val);
|
||||
@@ -50,23 +51,6 @@ protected:
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
// use inside namespace (?)
|
||||
#define REGISTER_TEMPLATEPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef TemplateProperty<TYPE> CLASS_NAME; \
|
||||
template <> std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>();
|
||||
|
||||
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
} \
|
||||
template <> template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>() { \
|
||||
return DEFAULT_VALUE; \
|
||||
}
|
||||
|
||||
#include "openspace/properties/templateproperty.inl"
|
||||
|
||||
#endif // __TEMPLATEPROPERTY_H__
|
||||
|
||||
@@ -25,21 +25,43 @@
|
||||
namespace openspace {
|
||||
namespace properties {
|
||||
|
||||
// check!
|
||||
template <typename T>
|
||||
TemplateProperty<T>::TemplateProperty(const std::string& identifier,
|
||||
const std::string& guiName)
|
||||
: TemplateProperty<T>(identifier, guiName,
|
||||
PropertyDelegate<TemplateProperty<T>>::template defaultValue<T>())
|
||||
{}
|
||||
#define REGISTER_TEMPLATEPROPERTY_HEADER(CLASS_NAME, TYPE) \
|
||||
typedef TemplateProperty<TYPE> CLASS_NAME; \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>();
|
||||
|
||||
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE) \
|
||||
template <> \
|
||||
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() { \
|
||||
return #CLASS_NAME; \
|
||||
\
|
||||
} \
|
||||
template <> \
|
||||
template <> \
|
||||
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>() { \
|
||||
return DEFAULT_VALUE; \
|
||||
\
|
||||
}
|
||||
|
||||
// Delegating constructors are necessary; automatic template deduction cannot
|
||||
// deduce template argument for 'U' if 'default' methods are used as default values in
|
||||
// a single constructor
|
||||
|
||||
template <typename T>
|
||||
TemplateProperty<T>::TemplateProperty(const std::string& identifier,
|
||||
const std::string& guiName, const T& value)
|
||||
: Property(identifier, guiName)
|
||||
, _value(value)
|
||||
{}
|
||||
TemplateProperty<T>::TemplateProperty(std::string identifier, std::string guiName)
|
||||
: TemplateProperty<T>(std::move(identifier), std::move(guiName),
|
||||
PropertyDelegate<TemplateProperty<T>>::defaultValue<T>()) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TemplateProperty<T>::TemplateProperty(std::string identifier, std::string guiName,
|
||||
T value)
|
||||
: Property(std::move(identifier), std::move(guiName))
|
||||
, _value(value) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string TemplateProperty<T>::className() const {
|
||||
@@ -57,5 +79,25 @@ TemplateProperty<T>& TemplateProperty<T>::operator=(T val) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
template <typename T>
|
||||
boost::any TemplateProperty<T>::get() const {
|
||||
return boost::any(_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TemplateProperty<T>::set(boost::any value) {
|
||||
try {
|
||||
_value = boost::any_cast<T>(std::move(value));
|
||||
}
|
||||
catch (boost::bad_any_cast&) {
|
||||
LERRORC("TemplateProperty", "Illegal cast to '" << typeid(T).name() << "'");
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const std::type_info& TemplateProperty<T>::type() const {
|
||||
return typeid(T);
|
||||
}
|
||||
|
||||
} // namespace properties
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user