DATAKIT API  V2025.1
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;
244  Dtk_bool IsNull() const;
245 };
246 
248 {
250 
255 
256 };
257 
259 
261 
263 {
264 private:
265  void _Init();
266  void _Reset();
267  friend class Dtk_SmartPtr<Dtk_MetaDataWithUnit>;
268 
269 protected :
272 
273 
274 public:
276  Dtk_MetaDataWithUnit(const MetaDataTypeEnum &inEnumType, Dtk_string inType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inUnit);
278 
280  inline Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
281  {
282  if (inId == _typeID) return 1;
283  return Dtk_MetaData::DtkDynamicType(inId);
284  }
285 
288  {
289  if (s->DtkDynamicType(_typeID)) return static_cast<Dtk_MetaDataWithUnit*>(s);
290  return NULL;
291  }
292 };
293 
303 class Dtk_MetaDataGroup;
304 
306 
308 {
309 protected :
311 private:
313  Dtk_string _GroupName;
314 
316  Dtk_tab< Dtk_MetaDataPtr > _MetadataChildren;
317 
318  void _Init();
319  void _Reset();
320 
321  friend class Dtk_SmartPtr<Dtk_MetaDataGroup>;
322 
323 public:
324 
327 
330 
332  inline Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
333  {
334  if( inId == _typeID ) return 1;
336  }
337 
340  {
341  if( s->DtkDynamicType(_typeID) ) return static_cast<Dtk_MetaDataGroup*>( s );
342  return NULL;
343  }
344 
346 
350 
353 
355  void SetName( Dtk_string inGroupName);
356 
359 
361  const Dtk_Size_t GetNumMetaData() const;
362 
365 };
366 
374 {
375 public:
376 
379 
380 
381 
385  const Dtk_string& GetType() const;
386 
390  void SetType( Dtk_string in) ;
391 
395  const Dtk_string& GetTitle() const;
396 
401 
405  const Dtk_string& GetValue() const;
406 
411 
412 
418  Dtk_ErrorStatus GetFormula(Dtk_string& outFormula,Dtk_string& outEstimatedValue,Dtk_string& outTitle,Dtk_string& outResultType) ;
419 
424  Dtk_string GetFormula(Dtk_string& outEstimatedValue) ;
431  void SetFormula( Dtk_string inFormula, Dtk_string inEstimatedValue, Dtk_string inTitle, Dtk_string inResultType);
432 
433 
435  virtual void conv_ptr(Dtk_Properties ** s){*s = this;}
436  int DtkDynamicType(const int& inId);
438 
439  void SetAsReal();
440  void SetAsInteger();
441  void SetAsBoolean();
442 
443  Dtk_bool IsReal() const;
448  Dtk_bool IsDate() const;
450  Dtk_bool IsNull() const;
451 
452 protected:
453  struct Dtk_Handle;
454  Dtk_Handle *_Private;
456  virtual ~Dtk_Properties();
457 
458  void _Init();
459  void _copy(const Dtk_Properties& s);
460  void _reset();
461  friend class Dtk_SmartPtr<Dtk_Properties>;
462 
463 };
464 
465 
466 #endif
Dtk_MetaData::Dtk_Handle::_Type
Dtk_string _Type
Definition: dtk_metadata.hpp:251
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:339
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:712
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_Object::_reset
void _reset()
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:254
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:725
Dtk_MetaData::Dtk_Handle
Definition: dtk_metadata.hpp:248
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:435
Dtk_Properties::_Init
void _Init()
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:252
Dtk_MetaData::IsFormula
Dtk_bool IsFormula() const
Dtk_MetaDataWithUnit::_Units
Dtk_string _Units
Definition: dtk_metadata.hpp:271
Dtk_MetaDataWithUnit
Definition: dtk_metadata.hpp:263
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:516
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:687
Dtk_MetaDataGroup::DtkDynamicType
Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
Retrieves the dynamic entity type.
Definition: dtk_metadata.hpp:332
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:249
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:453
Dtk_MetaData::IsBoolean
Dtk_bool IsBoolean() const
Dtk_MetaData::Dtk_Handle::_Value
Dtk_string _Value
Definition: dtk_metadata.hpp:253
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:308
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:303
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:258
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:517
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:287
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:518
dtk_object.hpp
Dtk_Properties::SetAsReal
void SetAsReal()
Dtk_Properties
This is the Dtk_Properties class.
Definition: dtk_metadata.hpp:374
Dtk_MetaDataWithUnit::DtkDynamicType
Dtk_Int32 DtkDynamicType(const Dtk_Int32 &inId)
Retrieves the dynamic entity type.
Definition: dtk_metadata.hpp:280
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:26
Dtk_Properties::GetType
const Dtk_string & GetType() const
Get the Type of the Property .