DATAKIT API  V2025.4
dtk_metadata.hpp
Go to the documentation of this file.
1 #ifndef __DTK_METADATA_HPP__
2 #define __DTK_METADATA_HPP__
3 
6 #include "def/define.h"
7 #include "util/error_dtk.hpp"
8 
9 class Dtk_Properties;
11 class Dtk_MetaData;
13 
22 class Dtk_MetaData : public Dtk_Object
23 {
24 public:
26  {
38  };
40  {
41  switch( inEnum )
42  {
43  case TypeProperty: return L"TypeProperty";
44  case TypeFileProperty: return L"TypeFileProperty";
45  case TypeConfigurationProperty: return L"TypeConfigurationProperty";
46  case TypeSheetMetal: return L"TypeSheetMetal";
47  case TypeParameter: return L"TypeParameter";
48  case TypeMassProperty: return L"TypeMassProperty";
49  case TypeElectricalProperty: return L"TypeElectricalProperty";
50  case TypeAttributeSet: return L"TypeAttributeSet";
51  case TypeUserAttribute: return L"TypeUserAttribute";
52  case TypeUserExpression: return L"TypeUserExpression";
53  default:
54  case TypeUnknown: return L"Unknown";
55  }
56  }
57 protected:
59  struct Dtk_Handle;
61 
63  Dtk_MetaData(const Dtk_MetaData& inToBeCopied);
65 
69 
71  virtual ~Dtk_MetaData();
72  friend class Dtk_SmartPtr<Dtk_MetaData>;
73 
74  void _Init();
75  void _Copy(const Dtk_MetaData& inToBeCopied);
76  void _Reset();
77 
78 
79 public:
84 // //! \brief Create a parameter Dtk_MetaDataPtr from a Dtk_PropertiesPtr.
85 // //! \param inObject Parameter data.
86 // //! \return the constructed Dtk_MetaDataPtr.
87 // static Dtk_MetaDataPtr CreateParameterMetaData(const Dtk_PropertiesPtr& inObject);
88 
95  static Dtk_MetaDataPtr CreateMetaData(const MetaDataTypeEnum &inEnumType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inValueType = Dtk_string(L"STRING"));
103  static Dtk_MetaDataPtr CreateMetaDataWithUnits(const MetaDataTypeEnum &inEnumType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inUnits, Dtk_string inValueType = Dtk_string(L"STRING"));
104 
106  inline Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
107  {
108  if (inId == _typeID) return 1;
109  return Dtk_Object::DtkDynamicType(inId);
110  }
111 
114  {
115  if (s->DtkDynamicType(_typeID)) return static_cast<Dtk_MetaData*>(s);
116  return NULL;
117  }
118 
124 
130 
136 
142 
148 
154 
155 //DTK_TOREMOVE_START
156 #ifdef AF51BDA7E49648f8AB95949F4CA52EF8
157  Dtk_PropertiesPtr ToSheetMetal();
158 #endif
159 //DTK_TOREMOVE_END
165  void SetMetaDataType( const MetaDataTypeEnum& inType );
166 
170  SetAsDeprecated("2022.1", "Use GetUnits(Dtk_string& outUnits) method instead.")
171  Dtk_string GetUnits() const;
172 
176  Dtk_ErrorStatus GetUnits( Dtk_string& outUnits ) const;
177 
181  const Dtk_string& GetType() const;
182 
185  void SetType( Dtk_string in) ;
186 
190  const Dtk_string& GetTitle() const;
193  void SetTitle( Dtk_string in) ;
194 
198  const Dtk_string& GetValue() const;
201  void SetValue( Dtk_string in) ;
202 
203 
207  const Dtk_string& GetCategory() const;
211 
212 
213 
214 
220  Dtk_ErrorStatus GetFormula(Dtk_string& outFormula,Dtk_string& outEstimatedValue,Dtk_string& outTitle,Dtk_string& outResultType) ;
221 
226  Dtk_string GetFormula(Dtk_string& outEstimatedValue) ;
227 
234  void SetFormula( Dtk_string inFormula, Dtk_string inEstimatedValue, Dtk_string inTitle, Dtk_string inResultType);
235 
236 
237  Dtk_bool IsReal() const;
242  Dtk_bool IsDate() const;
245  Dtk_bool IsNull() const;
246 };
247 
249 {
251 
256 
257 };
258 
260 
262 
264 {
265 private:
266  void _Init();
267  void _Reset();
268  friend class Dtk_SmartPtr<Dtk_MetaDataWithUnit>;
269 
270 protected :
273 
274 
275 public:
277  Dtk_MetaDataWithUnit(const MetaDataTypeEnum &inEnumType, Dtk_string inType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inUnit);
279 
281  inline Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
282  {
283  if (inId == _typeID) return 1;
284  return Dtk_MetaData::DtkDynamicType(inId);
285  }
286 
289  {
290  if (s->DtkDynamicType(_typeID)) return static_cast<Dtk_MetaDataWithUnit*>(s);
291  return NULL;
292  }
293 };
294 
304 class Dtk_MetaDataGroup;
305 
307 
309 {
310 protected :
312 private:
314  Dtk_string _GroupName;
315 
317  Dtk_tab< Dtk_MetaDataPtr > _MetadataChildren;
318 
319  void _Init();
320  void _Reset();
321 
322  friend class Dtk_SmartPtr<Dtk_MetaDataGroup>;
323 
324 public:
325 
328 
331 
333  inline Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
334  {
335  if( inId == _typeID ) return 1;
337  }
338 
341  {
342  if( s->DtkDynamicType(_typeID) ) return static_cast<Dtk_MetaDataGroup*>( s );
343  return NULL;
344  }
345 
347 
351 
354 
356  void SetName( Dtk_string inGroupName);
357 
360 
362  const Dtk_Size_t GetNumMetaData() const;
363 
366 };
367 
375 {
376 public:
377 
380 
381 
382 
386  const Dtk_string& GetType() const;
387 
391  void SetType( Dtk_string in) ;
392 
396  const Dtk_string& GetTitle() const;
397 
402 
406  const Dtk_string& GetValue() const;
407 
412 
413 
419  Dtk_ErrorStatus GetFormula(Dtk_string& outFormula,Dtk_string& outEstimatedValue,Dtk_string& outTitle,Dtk_string& outResultType) ;
420 
425  Dtk_string GetFormula(Dtk_string& outEstimatedValue) ;
432  void SetFormula( Dtk_string inFormula, Dtk_string inEstimatedValue, Dtk_string inTitle, Dtk_string inResultType);
433 
434 
436  virtual void conv_ptr(Dtk_Properties ** s){*s = this;}
437  int DtkDynamicType(const int& inId);
439 
440  void SetAsReal();
441  void SetAsInteger();
442  void SetAsBoolean();
443 
444  Dtk_bool IsReal() const;
449  Dtk_bool IsDate() const;
451  Dtk_bool IsNull() const;
452 
453 protected:
454  struct Dtk_Handle;
455  Dtk_Handle *_Private;
457  virtual ~Dtk_Properties();
458 
459  void _Init();
460  void _copy(const Dtk_Properties& s);
461  void _reset();
462  friend class Dtk_SmartPtr<Dtk_Properties>;
463 
464 };
465 
466 
467 #endif
Dtk_MetaData::Dtk_Handle::_Type
Dtk_string _Type
Definition: dtk_metadata.hpp:252
Dtk_MetaData::IsNull
Dtk_bool IsNull() const
Dtk_MetaData::CreatePropertiesMetaData
static Dtk_MetaDataPtr CreatePropertiesMetaData(const Dtk_PropertiesPtr &inObject)
Create a property Dtk_MetaDataPtr from a Dtk_PropertiesPtr.
Dtk_MetaData::TypeElectricalProperty
@ TypeElectricalProperty
Definition: dtk_metadata.hpp:34
Dtk_MetaData::~Dtk_MetaData
virtual ~Dtk_MetaData()
Destructor.
Dtk_MetaData::TypeUserAttribute
@ TypeUserAttribute
Definition: dtk_metadata.hpp:36
Dtk_MetaDataGroup::~Dtk_MetaDataGroup
virtual ~Dtk_MetaDataGroup()
Destructor.
Dtk_MetaDataGroup::CreateMetaDataGroup
static Dtk_MetaDataGroupPtr CreateMetaDataGroup(Dtk_string inGroupName, Dtk_tab< Dtk_MetaDataPtr > inMetadataChildren=Dtk_tab< Dtk_MetaDataPtr >())
Dtk_MetaData::SetType
void SetType(Dtk_string in)
Set the Type of the MetaData .
Dtk_MetaData::IsString
Dtk_bool IsString() const
Dtk_Properties::SetTitle
void SetTitle(Dtk_string)
Set the Title of the Property .
Dtk_Properties::GetFormula
Dtk_string GetFormula(Dtk_string &outEstimatedValue)
Get the Formula and its Estimated value of the Property .
Dtk_Properties::IsString
Dtk_bool IsString() const
Dtk_MetaData::SetMetaDataType
void SetMetaDataType(const MetaDataTypeEnum &inType)
Dtk_MetaDataWithUnit::Dtk_MetaDataWithUnit
Dtk_MetaDataWithUnit(const MetaDataTypeEnum &inEnumType, Dtk_string inType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inUnit)
Dtk_MetaDataGroup::DtkDynamicCast
static Dtk_MetaDataGroup * DtkDynamicCast(Dtk_Object *s)
Performs a dynamic cast - doesn't need RTTI -.
Definition: dtk_metadata.hpp:340
Dtk_MetaData::GetCategory
const Dtk_string & GetCategory() const
Get the Category of the MetaData .
Dtk_MetaData::DtkDynamicCast
static Dtk_MetaData * DtkDynamicCast(Dtk_Object *s)
Performs a dynamic cast - doesn't need RTTI -.
Definition: dtk_metadata.hpp:113
Dtk_MetaData::ToUserExpression
Dtk_PropertiesPtr ToUserExpression()
Retrieves the Dtk_MetaDataPtr as a parameter - if exists -.
Dtk_MetaData::SetValue
void SetValue(Dtk_string in)
Set the Value of the MetaData .
Dtk_MetaData::ToProperty
Dtk_PropertiesPtr ToProperty()
Retrieves the Dtk_MetaDataPtr as a property - if exists -.
Dtk_Properties::Dtk_Properties
Dtk_Properties(const Dtk_Properties &p)
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Dtk_MetaData::MetaDataType
const MetaDataTypeEnum & MetaDataType() const
Retrieves the Dtk_MetaDataPtr type - read only -.
Dtk_MetaData::_Private
Dtk_Handle * _Private
Definition: dtk_metadata.hpp:59
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:714
Dtk_MetaData::ToConfigurationProperty
Dtk_PropertiesPtr ToConfigurationProperty()
Dtk_MetaData::TypeFileProperty
@ TypeFileProperty
Definition: dtk_metadata.hpp:29
Dtk_MetaData::SetTitle
void SetTitle(Dtk_string in)
Set the Title of the MetaData .
Dtk_MetaData::TypeUserExpression
@ TypeUserExpression
Definition: dtk_metadata.hpp:37
Dtk_Properties::operator=
Dtk_Properties & operator=(const Dtk_Properties &p)
Dtk_MetaData::ToFileProperty
Dtk_PropertiesPtr ToFileProperty()
Dtk_MetaData::Dtk_Handle::_Category
Dtk_string _Category
Definition: dtk_metadata.hpp:255
Dtk_MetaData::MetaDataTypeEnumToString
static Dtk_string MetaDataTypeEnumToString(const MetaDataTypeEnum &inEnum)
Definition: dtk_metadata.hpp:39
Dtk_MetaData::_Copy
void _Copy(const Dtk_MetaData &inToBeCopied)
Dtk_bool
char Dtk_bool
Definition: define.h:727
Dtk_MetaData::Dtk_Handle
Definition: dtk_metadata.hpp:249
Dtk_MetaDataGroup::AddMetadata
void AddMetadata(Dtk_MetaDataPtr inChild)
Add a metadata to this Group.
Dtk_Properties::IsDate
Dtk_bool IsDate() const
Dtk_Properties::conv_ptr
virtual void conv_ptr(Dtk_Properties **s)
Definition: dtk_metadata.hpp:436
Dtk_Properties::_Init
void _Init()
Dtk_MetaData::IsTime_t
Dtk_bool IsTime_t() const
Dtk_MetaData::ToMassProperty
Dtk_PropertiesPtr ToMassProperty()
Retrieves the Dtk_MetaDataPtr as a parameter - if exists -.
Dtk_MetaData::GetTitle
const Dtk_string & GetTitle() const
Get the Title of the MetaData .
Dtk_MetaData::CreateMetaDataWithUnits
static Dtk_MetaDataPtr CreateMetaDataWithUnits(const MetaDataTypeEnum &inEnumType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inUnits, Dtk_string inValueType=Dtk_string(L"STRING"))
Create a Dtk_MetaDataPtr .
Dtk_Properties::~Dtk_Properties
virtual ~Dtk_Properties()
Dtk_Properties::SetAsInteger
void SetAsInteger()
Dtk_MetaData::_Reset
void _Reset()
Dtk_MetaDataPtr
Dtk_SmartPtr< Dtk_MetaData > Dtk_MetaDataPtr
Definition: dtk_metadata.hpp:11
Dtk_MetaData::IsReference
Dtk_bool IsReference() const
Dtk_Properties::GetValue
const Dtk_string & GetValue() const
Get the Value of the Property .
Dtk_MetaData::SetFormula
void SetFormula(Dtk_string inFormula, Dtk_string inEstimatedValue, Dtk_string inTitle, Dtk_string inResultType)
Set the MetaData as Formula .
Dtk_MetaData::Dtk_Handle::_Title
Dtk_string _Title
Definition: dtk_metadata.hpp:253
Dtk_MetaData::IsFormula
Dtk_bool IsFormula() const
Dtk_MetaDataWithUnit::_Units
Dtk_string _Units
Definition: dtk_metadata.hpp:272
Dtk_MetaDataWithUnit
Definition: dtk_metadata.hpp:264
Dtk_MetaData::IsReal
Dtk_bool IsReal() const
Dtk_Properties::SetAsBoolean
void SetAsBoolean()
Dtk_Properties::IsInteger
Dtk_bool IsInteger() const
Dtk_MetaData::Dtk_MetaData
Dtk_MetaData(const Dtk_MetaData &inToBeCopied)
Copy constructor.
Dtk_PropertiesPtr
Dtk_SmartPtr< Dtk_Properties > Dtk_PropertiesPtr
Definition: dtk_metadata.hpp:9
Dtk_MetaDataGroup::SetName
void SetName(Dtk_string inGroupName)
Set the group name.
DTK_TYPE_METADATA
@ DTK_TYPE_METADATA
Definition: define.h:518
Dtk_Properties::SetValue
void SetValue(Dtk_string)
Set the Value of the Property .
Dtk_MetaData::IsDate
Dtk_bool IsDate() const
Dtk_MetaData::GetValue
const Dtk_string & GetValue() const
Get the Value of the MetaData .
Dtk_Properties::create
static Dtk_PropertiesPtr create()
Dtk_MetaData::Dtk_MetaData
Dtk_MetaData(Dtk_MetaData &&inToBeMoved) DTK_NOEXCEPT
Dtk_MetaData::ToElectricalProperty
Dtk_PropertiesPtr ToElectricalProperty()
Retrieves the Dtk_MetaDataPtr as a parameter - if exists -.
Dtk_Properties::IsReal
Dtk_bool IsReal() const
Dtk_MetaDataWithUnit::GetUnits
Dtk_string GetUnits()
Dtk_MetaData::TypeConfigurationProperty
@ TypeConfigurationProperty
Definition: dtk_metadata.hpp:30
Dtk_Int32
int32_t Dtk_Int32
Definition: define.h:689
Dtk_MetaDataGroup::DtkDynamicType
Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
Retrieves the dynamic entity type.
Definition: dtk_metadata.hpp:333
Dtk_MetaData::TypeProperty
@ TypeProperty
Definition: dtk_metadata.hpp:28
Dtk_MetaData::TypeSheetMetal
@ TypeSheetMetal
Definition: dtk_metadata.hpp:31
Dtk_MetaData::Dtk_Handle::_MetaDataType
MetaDataTypeEnum _MetaDataType
Definition: dtk_metadata.hpp:250
Dtk_MetaDataGroup::Dtk_MetaDataGroup
Dtk_MetaDataGroup(Dtk_string inGroupName)
\Create MetaDataGroup
Dtk_MetaData::TypeUnknown
@ TypeUnknown
Definition: dtk_metadata.hpp:27
Dtk_MetaData::MetaDataTypeEnum
MetaDataTypeEnum
Definition: dtk_metadata.hpp:26
error_dtk.hpp
Dtk_MetaData::Dtk_MetaData
Dtk_MetaData(const MetaDataTypeEnum &inType)
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_MetaData::ToParameter
Dtk_PropertiesPtr ToParameter()
Retrieves the Dtk_MetaDataPtr as a parameter - if exists -.
Dtk_Properties::_Private
Dtk_Handle * _Private
Definition: dtk_metadata.hpp:454
Dtk_MetaData::IsBoolean
Dtk_bool IsBoolean() const
Dtk_MetaData::Dtk_Handle::_Value
Dtk_string _Value
Definition: dtk_metadata.hpp:254
Dtk_Properties::SetFormula
void SetFormula(Dtk_string inFormula, Dtk_string inEstimatedValue, Dtk_string inTitle, Dtk_string inResultType)
Set the MetaData as Formula .
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
Dtk_MetaDataGroup
Definition: dtk_metadata.hpp:309
Dtk_Properties::DtkDynamicType
int DtkDynamicType(const int &inId)
Dtk_MetaDataGroup::GetNumMetaData
const Dtk_Size_t GetNumMetaData() const
Get the number of metadatas in the Group.
Dtk_MetaData::TypeParameter
@ TypeParameter
Definition: dtk_metadata.hpp:32
Dtk_MetaDataGroup::GetGroupName
const Dtk_string GetGroupName()
Get the group name.
Dtk_Properties::SetType
void SetType(Dtk_string in)
Set the Type of the Property .
Dtk_MetaData::TypeAttributeSet
@ TypeAttributeSet
Definition: dtk_metadata.hpp:35
Dtk_MetaData::GetUnits
Dtk_ErrorStatus GetUnits(Dtk_string &outUnits) const
Get the Units of the MetaData.
Dtk_Properties::_copy
void _copy(const Dtk_Properties &s)
Dtk_Properties::DtkDynamicCast
static Dtk_Properties * DtkDynamicCast(Dtk_Object *s)
Dtk_MetaData::GetFormula
Dtk_ErrorStatus GetFormula(Dtk_string &outFormula, Dtk_string &outEstimatedValue, Dtk_string &outTitle, Dtk_string &outResultType)
Get the Formula Type of result and its Estimated value of the MetaData .
Dtk_Properties::IsNull
Dtk_bool IsNull() const
Dtk_MetaDataWithUnit::~Dtk_MetaDataWithUnit
virtual ~Dtk_MetaDataWithUnit()
Dtk_MetaDataGroup::GetListOfMetadatas
const Dtk_tab< Dtk_MetaDataPtr > & GetListOfMetadatas() const
Get the list of metadata of the MetaDataGroup.
define.h
Dtk_Properties::GetTitle
const Dtk_string & GetTitle() const
Get the Title of the Property .
Dtk_MetaData::ToUserAttribute
Dtk_PropertiesPtr ToUserAttribute()
Retrieves the Dtk_MetaDataPtr as a parameter - if exists -.
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
Dtk_MetaData::DtkDynamicType
Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
Retrieves the dynamic entity type.
Definition: dtk_metadata.hpp:106
Dtk_Properties::GetFormula
Dtk_ErrorStatus GetFormula(Dtk_string &outFormula, Dtk_string &outEstimatedValue, Dtk_string &outTitle, Dtk_string &outResultType)
Get the Formula Type of result and its Estimated value of the MetaData .
Dtk_Properties::Dtk_Properties
Dtk_Properties()
Dtk_Properties::IsBoolean
Dtk_bool IsBoolean() const
Dtk_MetaDataGroupPtr
Dtk_SmartPtr< Dtk_MetaDataGroup > Dtk_MetaDataGroupPtr
Definition: dtk_metadata.hpp:304
Dtk_MetaData::SetAsDeprecated
SetAsDeprecated("2022.1", "Use GetUnits(Dtk_string& outUnits) method instead.") Dtk_string GetUnits() const
Get the Units of the MetaData .
Dtk_MetaDataWithUnitPtr
Dtk_SmartPtr< Dtk_MetaDataWithUnit > Dtk_MetaDataWithUnitPtr
Definition: dtk_metadata.hpp:259
Dtk_Object::DtkDynamicType
virtual int DtkDynamicType(const int &inId)=0
Dtk_Properties::IsFormula
Dtk_bool IsFormula() const
Dtk_Object
Definition: dtk_object.hpp:8
dtk_string.hpp
Dtk_MetaData
This is the Dtk_MetaData Class. The Dtk_MetaDataPtr object is used to store any additional informatio...
Definition: dtk_metadata.hpp:23
Dtk_MetaData::TypeMassProperty
@ TypeMassProperty
Definition: dtk_metadata.hpp:33
Dtk_Properties::IsReference
Dtk_bool IsReference() const
Dtk_MetaData::SetCategory
void SetCategory(Dtk_string in)
Set the Category of the MetaData .
DTK_TYPE_METADATA_GROUP
@ DTK_TYPE_METADATA_GROUP
Definition: define.h:519
Dtk_MetaData::_Init
void _Init()
Dtk_MetaDataWithUnit::DtkDynamicCast
static Dtk_MetaDataWithUnit * DtkDynamicCast(Dtk_Object *s)
Performs a dynamic cast - doesn't need RTTI -.
Definition: dtk_metadata.hpp:288
Dtk_MetaData::_typeID
@ _typeID
Definition: dtk_metadata.hpp:58
Dtk_MetaData::GetType
const Dtk_string & GetType() const
Get the Type of the MetaData .
Dtk_MetaData::IsInteger
Dtk_bool IsInteger() const
DTK_TYPE_METADATAWITHUNIT
@ DTK_TYPE_METADATAWITHUNIT
Definition: define.h:520
dtk_object.hpp
Dtk_Properties::SetAsReal
void SetAsReal()
Dtk_Properties
This is the Dtk_Properties class.
Definition: dtk_metadata.hpp:375
Dtk_MetaDataWithUnit::DtkDynamicType
Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
Retrieves the dynamic entity type.
Definition: dtk_metadata.hpp:281
Dtk_MetaData::CreateMetaData
static Dtk_MetaDataPtr CreateMetaData(const MetaDataTypeEnum &inEnumType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inValueType=Dtk_string(L"STRING"))
Create a Dtk_MetaDataPtr .
Dtk_MetaDataGroup::GetMetaData
Dtk_MetaDataPtr GetMetaData(const Dtk_Size_t &inPos)
Get the inPos'th metadata of the Group.
DTK_NOEXCEPT
#define DTK_NOEXCEPT
Definition: config.hpp:30
Dtk_Properties::GetType
const Dtk_string & GetType() const
Get the Type of the Property .