QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_object.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
17//
18// virtual base class for all openNURBS objects
19//
21
22#if !defined(OPENNURBS_OBJECT_INC_)
23#define OPENNURBS_OBJECT_INC_
24
25
26class ON_ClassId; // used for runtime class identification
27
29//
30// Runtime class id
31//
32
33// Description:
34// Every class derived from ON_Object has a class id that records
35// its class name, baseclass name, and class uuid. The
36// ON_OBJECT_DECLARE and ON_OBJECT_IMPLEMENT macros generate
37// the code that creates and initializes class ids.
38//
39// The ON_Object::IsKindOf() and ON_Object::Cast() functions
40// use these class ids.
42{
43public:
44
45 // Description:
46 // This constructor is called to initialize each class id.
47 // The call is generated by the ON_OBJECT_IMPLEMENT macro.
48 //
49 // Parameters:
50 // sClassName - [in] name of the class (like ON_Geometry)
51 // sBaseClassName - [in] name of baseclass (like ON_Object)
52 // create - [in] function to create a new object(like CreateNewON_Geometry())
53 // copy - [in] function to copy
54 // sUUID - [in] UUID in registry format from Windows guidgen.exe
56 const char* sClassName,
57 const char* sBaseClassName,
58 ON_Object* (*create)(),
59 const char* sUUID
60 );
61
63 const char* sClassName,
64 const char* sBaseClassName,
65 ON_Object* (*create)(),
66 bool (*copy)(const ON_Object*,ON_Object* ),
67 const char* sUUID
68 );
69
71
72 // Description:
73 // Gets a class's ON_ClassId from the class's name.
74 // Parameters:
75 // sClassName - [in] name of class
76 // Returns:
77 // Pointer to the class's ON_ClassId.
78 // Example:
79 // const ON_ClassId* brep_id = ON_CLassId::ClassId("ON_Brep");
80 static const ON_ClassId* ClassId(
81 const char* sClassName
82 );
83
84 // Description:
85 // Gets a class's ON_ClassId from the class's uuid.
86 // Parameters:
87 // class_uuid - [in] uuid for the class
88 // Returns:
89 // Pointer to the class's ON_ClassId.
90 // Example:
91 // ON_UUID brep_uuid = ON_UuidFromString("60B5DBC5-E660-11d3-BFE4-0010830122F0");
92 // const ON_ClassId* brep_id = ON_CLassId::ClassId(brep_uuid);
93 static const ON_ClassId* ClassId(
94 ON_UUID class_uuid
95 );
96
97 // Description:
98 // Each class derived from ON_Object has a corresponding ON_ClassId
99 // stored in a linked list and the class is marked with an integer
100 // value. ON_ClassId::IncrementMark() increments the value used to
101 // mark new classes and returns the new marking value.
102 // Returns:
103 // Value that will be used to mark all future ON_ClassIds.
104 static int IncrementMark();
105 static int CurrentMark();
106 static const ON_ClassId* LastClassId();
107
108 // Description:
109 // Each class derived from ON_Object has a corresponding
110 // ON_ClassId stored in a linked list. If a class definition
111 // is going to disappear (which happens when the derived object
112 // definition is in a DLL that uses openNURBS as a DLL and the
113 // DLL containing the derived object's definition is unloaded),
114 // then the class's ON_ClassId needs to be removed from the class
115 // list. ON_ClassId::Purge( mark ) removes all ON_ClassIds with a
116 // a prescribed mark and returns the number of classes that
117 // were purged.
118 // Parameters:
119 // mark - [in] All ON_ClassIds with this mark will be purged.
120 // Returns:
121 // Number of classes that were purged.
122 // Example:
123 // // Call ON_ClassId::IncrementMark() BEFORE loading MY.DLL.
124 // int my_dll_classid_mark = ON_ClassId::IncrementMark();
125 // load MY.DLL with classes derived from ON_Object
126 // ...
127 // // Call ON_ClassId::Purge() BEFORE unloading MY.DLL.
128 // ON_ClassId::Purge( my_dll_classid_mark );
129 // unload MY.DLL
130 static int Purge(int mark);
131 static bool PurgeAfter(const ON_ClassId* pClassId);
132
133 // Description:
134 // Dumps the ON_ClassId list
135 // Parameters:
136 // dump - [in] destination for the text dump.
137 static void Dump(
138 ON_TextLog& dump
139 );
140
141 // Returns:
142 // class name
143 const char* ClassName() const;
144
145 // Returns:
146 // base class name
147 const char* BaseClassName() const;
148
149 // Returns:
150 // base class id
151 const ON_ClassId* BaseClass() const;
152
153 // Description:
154 // Determine if the class associated with this ON_ClassId
155 // is derived from another class.
156 // Parameters:
157 // potential_parent - [in] Class to test as parent.
158 // Returns:
159 // true if this is derived from potential_parent.
160 ON_BOOL32 IsDerivedFrom(
161 const ON_ClassId* potential_parent
162 ) const;
163
164 // Descrption:
165 // Create an instance of the class associated with
166 // class id.
167 // Returns:
168 // Instance of the class id's class.
169 ON_Object* Create() const;
170
171 // Returns:
172 // class uuid
173 ON_UUID Uuid() const;
174
175 /*
176 Description:
177 Opennurbs classes have a mark value of 0. Core Rhino
178 classes have a mark value of 1. Rhino plug-in classes
179 have a mark value of > 1.
180 Returns:
181 Class mark value
182 */
183 int Mark() const;
184
185 unsigned int ClassIdVersion() const;
186
187private:
188 static ON_ClassId* m_p0; // first id in the linked list of class ids
189 static ON_ClassId* m_p1; // last id in the linked list of class ids
190 static int m_mark0; // current mark value
191 ON_ClassId* m_pNext; // next in the linked list of class ids
192 const ON_ClassId* m_pBaseClassId; // base class id
193 char m_sClassName[80];
194 char m_sBaseClassName[80];
195 ON_Object* (*m_create)();
197 int m_mark; // bit 0x80000000 is used to indicate new extensions
198
199private:
200 // no implementaion to prohibit use
204
205 void ConstructorHelper(
206 const char* sClassName,
207 const char* sBaseClassName,
208 const char* sUUID
209 );
210
211 // This is a temporary way to add simple virtual functions
212 // to ON_Object without breaking the SDK. At V6 these will
213 // be redone to be ordinary virtual functions.
214 friend class ON_Object;
215 unsigned int m_class_id_version;
216 bool (*m_copy)(const ON_Object*,ON_Object*); // on version 1 class ids
217 void* m_f2;
218 void* m_f3;
219 void* m_f4;
220 void* m_f5;
221 void* m_f6;
222 void* m_f7;
223 void* m_f8;
224};
225
226// Description:
227// Macro to easily get a pointer to the ON_ClassId for a
228// given class;
229//
230// Example:
231//
232// const ON_ClassId* brep_class_id = ON_CLASS_ID("ON_Brep");
233//
234#define ON_CLASS_ID( cls ) ON_ClassId::ClassId( #cls )
235
236/*
237Description:
238 Expert user function to get the value of ON_ClassId::m_uuid
239 of the last instance of ON_ClassId to call ON_ClassId::Create().
240 This function was created to support Rhino's .NET SDK.
241 This function returns the value of a static id in
242 opennurbs_object.cpp and is NOT thread safe.
243Returns:
244 Value of ON_ClassId::m_uuid of the instance of ON_ClassId that
245 most recently called ON_ClassId::Create().
246*/
249
250typedef int (*ON_Vtable_func)(void);
251
253{
254 // The actual number of virtual functions depends on the class.
255 // The four in f[4] is just there to make it easy to see the
256 // first four in the debugger. There can be fewer or more
257 // than four virtual functions. The function prototype
258 // also depends on the class defintion. In particular,
259 // it is probably not int function(void).
261};
262
263/*
264Description:
265 Expert user function to get a pointer to
266 a class's vtable.
267Parameters:
268 pClass - [in] a class that has a vtable.
269 If you pass a class that does not have
270 a vtable, then the returned pointer is
271 garbage.
272Returns:
273 A pointer to the vtable.
274*/
276struct ON_Vtable* ON_ClassVtable(void* p);
277
278
279/*
280All classes derived from ON_Object must have
281
282 ON_OBJECT_DECLARE( <classname> );
283
284as the first line in their class definition an a corresponding
285
286 ON_VIRTUAL_OBJECT_IMPLEMENT( <classname>, <basclassname>, <classuuid> );
287
288or
289
290 ON_OBJECT_IMPLEMENT( <classname>, <basclassname>, <classuuid> );
291
292in a .CPP file.
293*/
294#define ON_OBJECT_DECLARE( cls ) \
295 protected: \
296 static void* m_s_##cls##_ptr; \
297 public: \
298 static const ON_ClassId m_##cls##_class_id; \
299 /*record used for ON_Object runtime type information*/ \
300 \
301 static cls * Cast( ON_Object* ); \
302 /*Description: Similar to C++ dynamic_cast*/ \
303 /*Returns: object on success. NULL on failure*/ \
304 \
305 static const cls * Cast( const ON_Object* ); \
306 /*Description: Similar to C++ dynamic_cast*/ \
307 /*Returns: object on success. NULL on failure*/ \
308 \
309 virtual const ON_ClassId* ClassId() const; \
310 /*Description:*/ \
311 \
312 private: \
313 virtual ON_Object* DuplicateObject() const; \
314 /*used by Duplicate to create copy of an object.*/ \
315 \
316 static bool Copy##cls( const ON_Object*, ON_Object* ); \
317 /* used by ON_Object::CopyFrom copy object into this. */ \
318 /* In V6 Copy##cls will vanish and be replaced with */ \
319 /* virtual bool CopyFrom( const ON_Object* src ) */ \
320 \
321 public: \
322 cls * Duplicate() const; \
323 /*Description: Expert level tool - no support available.*/ \
324 /*If this class is derived from CRhinoObject, use CRhinoObject::DuplicateRhinoObject instead*/
325
326// Objects derived from ON_Object that do not have a valid new, operator=,
327// or copy constructor must use ON_VIRTUAL_OBJECT_IMPLEMENT instead of
328// ON_OBJECT_IMPLEMENT. Objects defined with ON_VIRTUAL_OBJECT_IMPLEMENT
329// cannot be serialized using ON_BinaryArchive::ReadObject()/WriteObject()
330// or duplicated using ON_Object::Duplicate().
331//
332// The Cast() and ClassId() members work on objects defined with either
333// ON_VIRTUAL_OBJECT_IMPLEMENT or ON_OBJECT_IMPLEMENT.
334#define ON_VIRTUAL_OBJECT_IMPLEMENT( cls, basecls, uuid ) \
335 void* cls::m_s_##cls##_ptr = 0;\
336 const ON_ClassId cls::m_##cls##_class_id(#cls,#basecls,0,0,uuid);\
337 cls * cls::Cast( ON_Object* p) {return(cls *)Cast((const ON_Object*)p);} \
338 const cls * cls::Cast( const ON_Object* p) {return(p&&p->IsKindOf(&cls::m_##cls##_class_id))?(const cls *)p:0;} \
339 const ON_ClassId* cls::ClassId() const {return &cls::m_##cls##_class_id;} \
340 ON_Object* cls::DuplicateObject() const {return 0;} \
341 bool cls::Copy##cls( const ON_Object*, ON_Object* ) {return false;} \
342 cls * cls::Duplicate() const {return static_cast<cls *>(DuplicateObject());}
343
344// Objects derived from ON_Object that use ON_OBJECT_IMPLEMENT must
345// have a valid operator= and copy constructor. Objects defined with
346// ON_OBJECT_IMPLEMENT may be serialized using
347// ON_BinaryArchive::ReadObject()/WriteObject()
348// and duplicated by calling ON_Object::Duplicate().
349#define ON_OBJECT_IMPLEMENT( cls, basecls, uuid ) \
350 void* cls::m_s_##cls##_ptr = 0;\
351 static ON_Object* CreateNew##cls() {return new cls();} \
352 const ON_ClassId cls::m_##cls##_class_id(#cls,#basecls,CreateNew##cls,cls::Copy##cls,uuid);\
353 cls * cls::Cast( ON_Object* p) {return(cls *)Cast((const ON_Object*)p);} \
354 const cls * cls::Cast( const ON_Object* p) {return(p&&p->IsKindOf(&cls::m_##cls##_class_id))?(const cls *)p:0;} \
355 const ON_ClassId* cls::ClassId() const {return &cls::m_##cls##_class_id;} \
356 ON_Object* cls::DuplicateObject() const {cls* p = new cls(); if (p) *p=*this; return p;} \
357 bool cls::Copy##cls( const ON_Object* src, ON_Object* dst ){cls* d;const cls* s;if (0!=(s=cls::Cast(src))&&0!=(d=cls::Cast(dst))) {d->cls::operator=(*s);return true;}return false;} \
358 cls * cls::Duplicate() const {return static_cast<cls *>(DuplicateObject());}
359
360#define ON__SET__THIS__PTR(ptr) if (ptr) *((void**)this) = ptr
361
362class ON_UserData;
363
365{
366public:
371
372 void Dump(ON_TextLog& text_log) const;
373 bool Write(ON_BinaryArchive&) const;
374 bool Read(ON_BinaryArchive&);
375};
376
377#if defined(ON_DLL_TEMPLATE)
378// This stuff is here because of a limitation in the way Microsoft
379// handles templates and DLLs. See Microsoft's knowledge base
380// article ID Q168958 for details.
381#pragma warning( push )
382#pragma warning( disable : 4231 )
383ON_DLL_TEMPLATE template class ON_CLASS ON_ClassArray<ON_UserString>;
384#pragma warning( pop )
385#endif
386
388
389// Description:
390// Pure virtual base class for all classes that must provide
391// runtime class id or support object level 3DM serialization
393{
395 //
396 // Any object derived from ON_Object should have a
397 // ON_OBJECT_DECLARE(ON_...);
398 // as the last line of its class definition and a
399 // ON_OBJECT_IMPLEMENT( ON_..., ON_baseclass );
400 // in a .cpp file.
401 //
402 // These macros declare and implement public members
403 //
404 // static ON_ClassId m_ON_Object;
405 // static cls * Cast( ON_Object* );
406 // static const cls * Cast( const ON_Object* );
407 // virtual const ON_ClassId* ClassId() const;
409public:
410
411 /*
412 Description:
413 Copies src into this, if possible.
414 Parameters:
415 src - [in]
416 Returns:
417 True if this->operator= could be called to copy src.
418 Remarks:
419 This should be virtual function declared in the
420 ON_OBJECT_DECLARE macro along the lines of DuplicateObject()
421 but is was added after the SDK was frozen (adding virtual
422 functions breaks the SDK). In V6, the function will work
423 the same but be implemented like DuplicateObject();
424 */
425 bool CopyFrom( const ON_Object* src );
426
427public:
428
429#if defined(ON_DLL_EXPORTS) || defined(ON_DLL_IMPORTS)
430 // See comments at the top of opennurbs_object.cpp for details.
431
432 // new/delete
433 void* operator new(size_t);
434 void operator delete(void*);
435
436 // array new/delete
437 void* operator new[] (size_t);
438 void operator delete[] (void*);
439
440 // in place new/delete
441 void* operator new(size_t,void*);
442 void operator delete(void*,void*);
443#endif
444
445 ON_Object();
446 ON_Object( const ON_Object& );
447 ON_Object& operator=( const ON_Object& );
448 virtual ~ON_Object();
449
450 /*
451 Description:
452 The MemoryRelocate() function is called when an
453 object's location in memory is changed. For
454 example, if an object resides in a chunk of
455 memory that is grown by calling a realloc
456 that has to allocate a new chunk and
457 copy the contents of the old chunk to the
458 new chunk, then the location of the object's
459 memory changes. In practice this happens when
460 classes derived from ON_Object are stored
461 in dynamic arrays, like the default implementation
462 of ON_ObjectArray<>'s that use realloc to grow
463 the dynamic array.
464 */
465 virtual
466 void MemoryRelocate();
467
468 /*
469 Description:
470 Low level tool to test if an object is derived
471 from a specified class.
472 Parameters:
473 pClassId - [in] use classname::ClassId()
474 Returns:
475 true if the instantiated object is derived from the
476 class whose id is passed as the argument.
477 Example:
478
479 ON_Object* p = ....;
480 if ( p->IsKindOf( ON_NurbsCurve::ClassId() ) )
481 {
482 it's a NURBS curve
483 }
484
485 Remarks:
486 The primary reason for IsKindOf() is to support the
487 static Cast() members declared in the ON_OBJECT_DECLARE
488 macro. If we determine that dynamic_cast is properly
489 supported and implemented by all supported compilers,
490 then IsKindOf() may dissappear. If an application needs
491 to determine if a pointer points to a class derived from
492 ON_SomeClassName, then call
493 ON_SomeClassName::Cast(mystery pointer) and check for
494 a non-null return.
495 */
496 ON_BOOL32 IsKindOf(
497 const ON_ClassId* pClassId
498 ) const;
499
500 /*
501 Description:
502 Tests an object to see if its data members are correctly
503 initialized.
504 Parameters:
505 text_log - [in] if the object is not valid and text_log
506 is not NULL, then a brief englis description of the
507 reason the object is not valid is appened to the log.
508 The information appended to text_log is suitable for
509 low-level debugging purposes by programmers and is
510 not intended to be useful as a high level user
511 interface tool.
512 Returns:
513 @untitled table
514 true object is valid
515 false object is invalid, uninitialized, etc.
516 */
517 virtual
518 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const = 0;
519
520 /*
521 Description:
522 Creates a text dump of the object.
523 Remarks:
524 Dump() is intended for debugging and is not suitable
525 for creating high quality text descriptions of an
526 object.
527
528 The default implementations of this virtual function
529 prints the class's name.
530 */
531 virtual
532 void Dump( ON_TextLog& ) const;
533
534 /*
535 Returns:
536 An estimate of the amount of memory the class uses in bytes.
537 */
538 virtual
539 unsigned int SizeOf() const;
540
541 /*
542 Description:
543 Returns a CRC calculated from the information that defines
544 the object. This CRC can be used as a quick way to see
545 if two objects are not identical.
546 Parameters:
547 current_remainder - [in];
548 Returns:
549 CRC of the information the defines the object.
550 */
551 virtual
552 ON__UINT32 DataCRC(ON__UINT32 current_remainder) const;
553
554 /*
555 Description:
556 Low level archive writing tool used by ON_BinaryArchive::WriteObject().
557 Parameters:
558 binary_archive - archive to write to
559 Returns:
560 Returns true if the write is successful.
561 Remarks:
562 Use ON_BinaryArchive::WriteObject() to write objects.
563 This Write() function should just write the specific definition of
564 this object. It should not write and any chunk typecode or length
565 information.
566
567 The default implementation of this virtual function returns
568 false and does nothing.
569 */
570 virtual
571 ON_BOOL32 Write(
572 ON_BinaryArchive& binary_archive
573 ) const;
574
575 /*
576 Description:
577 Low level archive writing tool used by ON_BinaryArchive::ReadObject().
578 Parameters:
579 binary_archive - archive to read from
580 Returns:
581 Returns true if the read is successful.
582 Remarks:
583 Use ON_BinaryArchive::ReadObject() to read objects.
584 This Read() function should read the objects definition back into
585 its data members.
586
587 The default implementation of this virtual function returns
588 false and does nothing.
589 */
590 virtual
591 ON_BOOL32 Read(
592 ON_BinaryArchive& binary_archive
593 );
594
595 /*
596 Description:
597 Useful for switch statements that need to differentiate
598 between basic object types like points, curves, surfaces,
599 and so on.
600
601 Returns:
602 ON::object_type enum value.
603
604 @untitled table
605 ON::unknown_object_type unknown object
606 ON::point_object derived from ON_Point
607 ON::pointset_object some type of ON_PointCloud, ON_PointGrid, ...
608 ON::curve_object derived from ON_Curve
609 ON::surface_object derived from ON_Surface
610 ON::brep_object derived from ON_Brep
611 ON::extrusion_object derived from ON_Extrusion
612 ON::mesh_object derived from ON_Mesh
613 ON::layer_object derived from ON_Layer
614 ON::material_object derived from ON_Material
615 ON::light_object derived from ON_Light
616 ON::annotation_object derived from ON_Annotation,
617 ON::userdata_object derived from ON_UserData
618 ON::text_dot derived from ON_TextDot
619
620 Remarks:
621 The default implementation of this virtual function returns
622 ON::unknown_object_type
623 */
624 virtual
625 ON::object_type ObjectType() const;
626
627
628
629 /*
630 Description:
631 All objects in an opennurbs model have an id
632 ( ON_Layer.m_layer_id, ON_Font.m_font_id,
633 ON_Material.m_material_id, ON_3dmObjectAttributes.m_uuid
634 ).
635 Returns:
636 The id used to identify the object in the openurbs model.
637 */
638 virtual
639 ON_UUID ModelObjectId() const;
640
642 //
643 // User data provides a standard way for extra information to
644 // be attached to any class derived from ON_Object. The attached
645 // information can persist and be transformed. If you use user
646 // data, please carefully read all the comments from here to the
647 // end of the file.
648 //
649
650 /*
651 Description:
652 Attach a user string to an object. This information will
653 perisist through copy construction, operator=, and file IO.
654 Parameters:
655 key - [in] id used to retrieve this string.
656 string_value - [in]
657 If NULL, the string with this id will be removed.
658 Returns:
659 True if successful.
660 */
661 bool SetUserString(
662 const wchar_t* key,
663 const wchar_t* string_value
664 );
665
666 /*
667 Description:
668 Get user string from an object.
669 Parameters:
670 key - [in] id used to retrieve the string.
671 string_value - [out]
672 Returns:
673 True if a string with id was found.
674 */
675 bool GetUserString(
676 const wchar_t* key,
677 ON_wString& string_value
678 ) const;
679
680 /*
681 Description:
682 Get a list of all user strings on an object.
683 Parameters:
684 user_strings - [out]
685 user strings are appended to this list.
686 Returns:
687 Number of elements appended to the user_strings list.
688 */
689 int GetUserStrings(
690 ON_ClassArray<ON_UserString>& user_strings
691 ) const;
692
693 /*
694 Description:
695 Get a list of all user string keys on an object.
696 Parameters:
697 user_string_keys - [out]
698 user string keys are appended to this list.
699 Returns:
700 Number of elements appended to the user_strings list.
701 */
702 int GetUserStringKeys(
703 ON_ClassArray<ON_wString>& user_string_keys
704 ) const;
705
706 /*
707 Description:
708 Attach user data to an object.
709 Parameters:
710 pUserData - [in] user data to attach to object.
711 The ON_UserData pointer passed to AttachUserData()
712 must be created with new.
713 Returns:
714 If true is returned, then ON_Object will delete the user
715 data when appropriate. If false is returned, then data
716 could not be attached and caller must delete.
717 Remarks:
718 AttachUserData() will fail if the user data's m_userdata_uuid
719 field is nil or not unique.
720 */
721 ON_BOOL32 AttachUserData(
722 ON_UserData* pUserData
723 );
724
725 /*
726 Description:
727 Remove user data from an object.
728 Parameters:
729 pUserData - [in] user data to attach to object.
730 The ON_UserData pointer passed to DetachUserData()
731 must have been previously attached using
732 AttachUserData().
733 Returns:
734 If true is returned, then the user data was
735 attached to this object and it was detached. If false
736 is returned, then the user data was not attached to this
737 object to begin with. In all cases, you can be assured
738 that the user data is no longer attached to "this".
739 Remarks:
740 Call delete pUserData if you want to destroy the user data.
741 */
742 ON_BOOL32 DetachUserData(
743 ON_UserData* pUserData
744 );
745
746
747 /*
748 Description:
749 Get a pointer to user data.
750 Parameters:
751 userdata_uuid - [in] value of the user data's
752 m_userdata_uuid field.
753 Remarks:
754 The returned user data is still attached to the object.
755 Deleting the returned user data will automatically remove
756 the user data from the object.
757 */
758 ON_UserData* GetUserData(
759 const ON_UUID& userdata_uuid
760 ) const;
761
762 /*
763 Description:
764 PurgeUserData() removes all user data from object.
765 Remarks:
766 Use delete GetUserData(...) to destroy a single piece
767 of user data.
768 */
769 void PurgeUserData();
770
771 /*
772 Description:
773 User data is stored as a linked list of ON_UserData
774 classes. FirstUserData gets the first item in the
775 linked list. This is the most recent item attached
776 using AttachUserData().
777 Remark:
778 To iterate through all the user data on an object,
779 call FirstUserData() and then use ON_UserData::Next()
780 to traverse the list.
781 */
782 ON_UserData* FirstUserData() const;
783
784 /*
785 Description:
786 Objects derived from ON_Geometry must call
787 TransformUserData() in their Transform() member function.
788 Parameters:
789 xform - [in] transformation to apply to user data
790 */
791 void TransformUserData(
792 const ON_Xform& xform
793 );
794
795 /*
796 Description:
797 Expert user tool that copies user data that has a positive
798 m_userdata_copycount from the source_object to this.
799 Parameters:
800 source_object - [in] source of user data to copy
801 Remarks:
802 Generally speaking you don't need to use CopyUserData().
803 Simply rely on ON_Object::operator=() or the copy constructor
804 to do the right thing.
805 */
806 void CopyUserData(
807 const ON_Object& source_object
808 );
809
810 /*
811 Description:
812 Expert user tool Moves user data from source_object
813 to this, including user data with a nil m_userdata_copycount.
814 Deletes any source user data with a duplicate m_userdata_uuid
815 on this.
816 */
817 void MoveUserData(
818 ON_Object& source_object
819 );
820
821
823 //
824 // Expert interface
825 //
826
827 /*
828 Description:
829 Expert user function. If you are using openNURBS in its
830 default configuration to read and write 3dm archives,
831 you never need to call this function.
832 Many objects employ lazy creation of (runtime) caches
833 that save information to help speed geometric calculations.
834 This function will destroy all runtime information.
835 Parameters:
836 bDelete - [in] if true, any cached information is properly
837 deleted. If false, any cached information
838 is simply discarded. This is useful when
839 the cached information may be in alternate
840 memory pools that are managed in nonstandard
841 ways.
842 */
843 virtual
844 void DestroyRuntimeCache( bool bDelete = true );
845
846 ON_MEMORY_POOL* m_mempool; // memory pool for this object (typically null)
847private:
852 friend class ON_UserData;
854};
855
856#endif
857
@ Uuid
Definition RSMetaType.h:69
Definition opennurbs_archive.h:152
int ReadObject(ON_Object **ppObject)
Definition opennurbs_archive.cpp:3117
bool WriteObject(const ON_Object *)
Definition opennurbs_archive.cpp:2778
bool ReadObjectUserData(ON_Object &object)
Definition opennurbs_archive.cpp:3558
bool WriteObjectUserData(const ON_Object &object)
Definition opennurbs_archive.cpp:2938
Definition opennurbs_array.h:760
Definition opennurbs_object.h:42
static ON_ClassId * m_p0
Definition opennurbs_object.h:188
void * m_f6
Definition opennurbs_object.h:221
static int m_mark0
Definition opennurbs_object.h:190
void * m_f5
Definition opennurbs_object.h:220
ON_ClassId & operator=(const ON_ClassId &)
static ON_ClassId * m_p1
Definition opennurbs_object.h:189
const ON_ClassId * m_pBaseClassId
Definition opennurbs_object.h:192
ON_UUID m_uuid
Definition opennurbs_object.h:196
int m_mark
Definition opennurbs_object.h:197
ON_ClassId * m_pNext
Definition opennurbs_object.h:191
ON_ClassId(const ON_ClassId &)
void * m_f3
Definition opennurbs_object.h:218
void * m_f4
Definition opennurbs_object.h:219
void * m_f7
Definition opennurbs_object.h:222
void * m_f2
Definition opennurbs_object.h:217
unsigned int m_class_id_version
Definition opennurbs_object.h:215
void * m_f8
Definition opennurbs_object.h:223
Definition opennurbs_object.h:393
virtual ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const =0
ON_OBJECT_DECLARE(ON_Object)
ON_MEMORY_POOL * m_mempool
Definition opennurbs_object.h:846
ON_UserData * m_userdata_list
Definition opennurbs_object.h:853
friend class ON_UserData
Definition opennurbs_object.h:852
Definition opennurbs_textlog.h:20
Definition opennurbs_uuid.h:31
Definition opennurbs_userdata.h:20
Definition opennurbs_object.h:365
ON_wString m_string_value
Definition opennurbs_object.h:370
ON_wString m_key
Definition opennurbs_object.h:369
Definition opennurbs_xform.h:28
Definition opennurbs_string.h:392
#define ON_DECL
Definition opennurbs_defines.h:92
#define ON_CLASS
Definition opennurbs_defines.h:91
ON_DECL struct ON_Vtable * ON_ClassVtable(void *p)
Definition opennurbs_object.cpp:1876
ON_DECL ON_UUID ON_GetMostRecentClassIdCreateUuid()
Definition opennurbs_object.cpp:932
int(* ON_Vtable_func)(void)
Definition opennurbs_object.h:250
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362
unsigned int ON__UINT32
Definition opennurbs_system.h:326
Definition opennurbs_object.h:253
ON_Vtable_func f[4]
Definition opennurbs_object.h:260
Definition opennurbs_memory.h:207