/usr/include/root/Reflex/internal/TypeBase.h is in libroot-core-dev 5.34.14-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | // @(#)root/reflex:$Id$
// Author: Stefan Roiser 2004
// Copyright CERN, CH-1211 Geneva 23, 2004-2010, All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.
#ifndef Reflex_TypeBase
#define Reflex_TypeBase
// Include files
#include "Reflex/Kernel.h"
#include "Reflex/Scope.h"
#include "Reflex/internal/OwnedPropertyList.h"
#include <vector>
#include <typeinfo>
namespace Reflex {
// forward declarations
class Type;
class Object;
class TypeTemplate;
class TypeName;
class DictionaryGenerator;
/**
* @class TypeBase TypeBase.h Reflex/TypeBase.h
* @author Stefan Roiser
* @date 24/11/2003
* @ingroup Ref
*/
class RFLX_API TypeBase {
private:
TypeBase(const TypeBase&); // not implemented
TypeBase& operator=(const TypeBase&); // not implemented
public:
/** default constructor */
TypeBase(const char* nam,
size_t size,
TYPE typeTyp,
const std::type_info & ti,
const Type& finalType = Dummy::Type(),
REPRESTYPE represType = REPRES_NOTYPE);
/** destructor */
virtual ~TypeBase();
/**
* operator Scope will return the corresponding scope of this type if
* applicable (i.e. if the Type is also a Scope e.g. Class, Union, Enum)
*/
operator Scope() const;
/**
* operator Type will return the corresponding Type object
* @return Type corresponding to this TypeBase
*/
operator Type() const;
/**
* Allocate will reserve memory for the size of the object
* @return pointer to allocated memory
*/
void* Allocate() const;
/**
* CastObject an object from this class At to another one
* @param to is the class At to cast into
* @param obj the memory AddressGet of the object to be casted
*/
virtual Object CastObject(const Type& to,
const Object& obj) const;
/**
* Construct will call the constructor of a given At and Allocate the
* memory for it
* @param signature of the constructor
* @param values for parameters of the constructor
* @param mem place in memory for implicit construction
* @return pointer to new instance
*/
/*
virtual Object Construct( const Type & signature,
const std::vector < Object > & values,
void * mem ) const;*/
virtual Object Construct(const Type& signature,
const std::vector<void*>& values,
void* mem) const;
/**
* Deallocate will Deallocate the memory for a given object
* @param instance of the At in memory
*/
void Deallocate(void* instance) const;
/**
* Destruct will call the destructor of a At and remove its memory
* allocation if desired
* @param instance of the At in memory
* @param dealloc for also deallacoting the memory
*/
virtual void Destruct(void* instance,
bool dealloc = true) const;
/**
* DeclaringScope will return a pointer to the At of this one
* @return pointer to declaring At
*/
Scope DeclaringScope() const;
/**
* DynamicType is used to discover whether an object represents the
* current class At or not
* @param mem is the memory AddressGet of the object to checked
* @return the actual class of the object
*/
virtual Type DynamicType(const Object& obj) const;
/**
* FinalType will return the type without typedefs
* @return type with all typedef info removed
*/
Type FinalType() const;
/**
* GenerateDict will produce the dictionary information of this type
* @param generator a reference to the dictionary generator instance
*/
virtual void GenerateDict(DictionaryGenerator& generator) const;
/**
* GetBasePosition will return fBasePosition
* @return The position where the unscoped Name starts in the typename
*/
size_t GetBasePosition() const;
/**
* IsAbstract will return true if the the class is abstract
* @return true if the class is abstract
*/
virtual bool IsAbstract() const;
/**
* IsArray returns true if the At represents a Array
* @return true if At represents a Array
*/
bool IsArray() const;
/**
* IsClass returns true if the At represents a Class
* @return true if At represents a Class
*/
bool IsClass() const;
/**
* IsComplete will return true if all classes and BaseAt classes of this
* class are resolved and fully known in the system
*/
virtual bool IsComplete() const;
/**
* IsEnum returns true if the At represents a Enum
* @return true if At represents a Enum
*/
bool IsEnum() const;
/**
* IsFunction returns true if the At represents a Function
* @return true if At represents a Function
*/
bool IsFunction() const;
/**
* IsFundamental returns true if the At represents a Fundamental
* @return true if At represents a Fundamental
*/
bool IsFundamental() const;
/**
* IsPointer returns true if the At represents a Pointer
* @return true if At represents a Pointer
*/
bool IsPointer() const;
/**
* IsPointerToMember returns true if the At represents a PointerToMember
* @return true if At represents a PointerToMember
*/
bool IsPointerToMember() const;
/**
* IsPrivate will check if the scope access is private
* @return true if scope access is private
*/
virtual bool IsPrivate() const;
/**
* IsProtected will check if the scope access is protected
* @return true if scope access is protected
*/
virtual bool IsProtected() const;
/**
* IsPublic will check if the scope access is public
* @return true if scope access is public
*/
virtual bool IsPublic() const;
/**
* IsStruct will return true if the At represents a struct (not a class)
* @return true if At represents a struct
*/
bool IsStruct() const;
/**
* IsTemplateInstance will return true if the the class is templated
* @return true if the class is templated
*/
bool IsTemplateInstance() const;
/**
* IsTypedef returns true if the At represents a Typedef
* @return true if At represents a Typedef
*/
bool IsTypedef() const;
/**
* IsUnion returns true if the At represents a Union
* @return true if At represents a
*/
bool IsUnion() const;
/**
* IsVirtual will return true if the class contains a virtual table
* @return true if the class contains a virtual table
*/
virtual bool IsVirtual() const;
/** Array
* size returns the size of the array
* @return size of array
*/
virtual size_t ArrayLength() const;
/**
* Name returns the name of the type
* @return name of type
*/
virtual std::string Name(unsigned int mod = 0) const;
/**
* SimpleName returns the name of the type as a reference. It provides a
* simplified but faster generation of a type name. Attention currently it
* is not guaranteed that Name() and SimpleName() return the same character
* layout of a name (ie. spacing, commas, etc. )
* @param pos will indicate where in the returned reference the requested name starts
* @param mod The only 'mod' support is SCOPED
* @return name of type
*/
virtual const char* SimpleName(size_t& pos,
unsigned int mod = 0) const;
/**
* FunctionParameterAt returns the nth FunctionParameterAt
* @param nth nth FunctionParameterAt
* @return pointer to nth FunctionParameterAt At
*/
virtual Type FunctionParameterAt(size_t nth) const;
/**
* FunctionParameterSize will return the number of parameters of this function
* @return number of parameters
*/
virtual size_t FunctionParameterSize() const;
virtual Type_Iterator FunctionParameter_Begin() const;
virtual Type_Iterator FunctionParameter_End() const;
virtual Reverse_Type_Iterator FunctionParameter_RBegin() const;
virtual Reverse_Type_Iterator FunctionParameter_REnd() const;
/**
* PointerToMemberScope will return the scope of the pointer to member type
* @return scope of the pointer to member type
*/
virtual Scope PointerToMemberScope() const;
/**
* Properties will return a pointer to the PropertyNth list attached
* to this item
* @return pointer to PropertyNth list
*/
virtual PropertyList Properties() const;
/**
* RawType will return the underlying type of a type removing all information
* of pointers, arrays, typedefs
* @return the raw type representation
*/
Type RawType() const;
/**
* ReturnType will return a pointer to the At of the return At.
* @return pointer to Type of return At
*/
virtual Type ReturnType() const;
/**
* sizeof will return the size of the At
* @return size of the At as int
*/
size_t SizeOf() const;
/**
* TemplateArgumentAt will return a pointer to the nth template argument
* @param nth nth template argument
* @return pointer to nth template argument
*/
virtual Type TemplateArgumentAt(size_t nth) const;
/**
* templateArgSize will return the number of template arguments
* @return number of template arguments
*/
virtual size_t TemplateArgumentSize() const;
virtual Type_Iterator TemplateArgument_Begin() const;
virtual Type_Iterator TemplateArgument_End() const;
virtual Reverse_Type_Iterator TemplateArgument_RBegin() const;
virtual Reverse_Type_Iterator TemplateArgument_REnd() const;
/**
* TemplateFamily returns the corresponding TypeTemplate if any
* @return corresponding TypeTemplate
*/
virtual TypeTemplate TemplateFamily() const;
/**
* arrayType will return a pointer to the At of the array.
* @return pointer to Type of MemberAt et. al.
*/
virtual Type ToType() const;
/**
* At returns the corresponding unqualified Type object
* @return corresponding At object
*/
Type ThisType() const;
/**
* TypeInfo will return the c++ type_info object of the At
* @return type_info object of At
*/
virtual const std::type_info& TypeInfo() const;
/**
* TypeType will return the real At
* @return real At
*/
TYPE TypeType() const;
/**
* TypeTypeAsString will return the string representation of the TYPE At
* @return string representation of TYPE At
*/
std::string TypeTypeAsString() const;
public:
/**
* SetSize will set the size of the type. This function shall
* be used with care. It will change the reflection information
* of this type.
*/
void SetSize(size_t s) const;
/**
* SetTypeInfo will set the type_info object of this type.
* Attention: This will change the reflection information
* of this type.
*/
void SetTypeInfo(const std::type_info& ti) const;
/**
* Hide this type from any lookup by appending the string " @HIDDEN@" to its name.
*/
virtual void HideName() const;
/**
* Un-Hide this type from any lookup by removing the string " @HIDDEN@" to its name.
*/
virtual void UnhideName() const;
REPRESTYPE
RepresType() const { return fRepresType; }
protected:
/**
* DetermineFinalType will return the t without typedefs
* @return type with all typedef info removed
*/
Type DetermineFinalType(const Type& t) const;
/**
* Calculate the size for types based on other types,
* if the other type was not yet available to calculate the
* size at construction time.
* @return The calculated size, 0 if the underlying size is unknown.
*/
virtual size_t CalculateSize() const;
/**
* Pointer to the TypeName
* @label At Name
* @ling aggregation
* @link aggregation
* @supplierCardinality 1
* @clientCardinality 1
*/
TypeName* fTypeName;
/** C++ type_info object */
mutable
const std::type_info * fTypeInfo;
private:
REPRESTYPE fRepresType;
/**
* The Scope of the Type
* @label type scope
* @link aggregation
* @clientCardinality 1
* @supplierCardinality 1
*/
Scope fScope;
/** size of the type in int */
mutable
size_t fSize;
/**
* TYPE (kind) of the Type
* @link aggregation
* @label type type
* @clientCardinality 1
* @supplierCardinality 1
*/
TYPE fTypeType;
/**
* Property list attached to this type
* @label propertylist
* @link aggregationByValue
* @clientCardinality 1
* @supplierCardinality 1
*/
OwnedPropertyList fPropertyList;
/**
* The position where the unscoped Name starts in the typename
*/
size_t fBasePosition;
/**
* the final type excluding typedefs
* @label final typedef type
* @link aggregation
* @supplierCardinality 0..1
* @clientCardinality 1
*/
mutable
Type * fFinalType;
/**
* the raw type excluding pointers, typedefs and arrays
* @label raw type
* @link aggregation
* @supplierCardinality 0..1
* @clientCardinality 1
*/
mutable
Type * fRawType;
}; // class TypeBase
} //namespace Reflex
#include "Reflex/TypeTemplate.h"
//-------------------------------------------------------------------------------
inline size_t
Reflex::TypeBase::CalculateSize() const {
//-------------------------------------------------------------------------------
return fSize;
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::TypeBase::GetBasePosition() const {
//-------------------------------------------------------------------------------
return fBasePosition;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsAbstract() const {
//-------------------------------------------------------------------------------
return false;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsArray() const {
//-------------------------------------------------------------------------------
return fTypeType == ARRAY;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsClass() const {
//-------------------------------------------------------------------------------
return fTypeType == CLASS ||
fTypeType == TYPETEMPLATEINSTANCE ||
fTypeType == STRUCT;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsComplete() const {
//-------------------------------------------------------------------------------
return true;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsEnum() const {
//-------------------------------------------------------------------------------
return fTypeType == ENUM;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsFunction() const {
//-------------------------------------------------------------------------------
return fTypeType == FUNCTION;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsFundamental() const {
//-------------------------------------------------------------------------------
return fTypeType == FUNDAMENTAL;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsPointer() const {
//-------------------------------------------------------------------------------
return fTypeType == POINTER;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsStruct() const {
//-------------------------------------------------------------------------------
return fTypeType == STRUCT;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsPointerToMember() const {
//-------------------------------------------------------------------------------
return fTypeType == POINTERTOMEMBER;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsTemplateInstance() const {
//-------------------------------------------------------------------------------
return fTypeType == TYPETEMPLATEINSTANCE ||
fTypeType == MEMBERTEMPLATEINSTANCE;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsTypedef() const {
//-------------------------------------------------------------------------------
return fTypeType == TYPEDEF;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsUnion() const {
//-------------------------------------------------------------------------------
return fTypeType == UNION;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsPrivate() const {
//-------------------------------------------------------------------------------
return false;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsProtected() const {
//-------------------------------------------------------------------------------
return false;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsPublic() const {
//-------------------------------------------------------------------------------
return false;
}
//-------------------------------------------------------------------------------
inline bool
Reflex::TypeBase::IsVirtual() const {
//-------------------------------------------------------------------------------
return false;
}
//-------------------------------------------------------------------------------
inline Reflex::Type_Iterator
Reflex::TypeBase::FunctionParameter_Begin() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().begin();
}
//-------------------------------------------------------------------------------
inline Reflex::Type_Iterator
Reflex::TypeBase::FunctionParameter_End() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().end();
}
//-------------------------------------------------------------------------------
inline Reflex::Reverse_Type_Iterator
Reflex::TypeBase::FunctionParameter_RBegin() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().rbegin();
}
//-------------------------------------------------------------------------------
inline Reflex::Reverse_Type_Iterator
Reflex::TypeBase::FunctionParameter_REnd() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().rend();
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::TypeBase::SizeOf() const {
//-------------------------------------------------------------------------------
if (!fSize) {
fSize = CalculateSize();
}
return fSize;
}
//-------------------------------------------------------------------------------
inline size_t
Reflex::TypeBase::TemplateArgumentSize() const {
//-------------------------------------------------------------------------------
return 0;
}
//-------------------------------------------------------------------------------
inline Reflex::Type_Iterator
Reflex::TypeBase::TemplateArgument_Begin() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().begin();
}
//-------------------------------------------------------------------------------
inline Reflex::Type_Iterator
Reflex::TypeBase::TemplateArgument_End() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().end();
}
//-------------------------------------------------------------------------------
inline Reflex::Reverse_Type_Iterator
Reflex::TypeBase::TemplateArgument_RBegin() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().rbegin();
}
//-------------------------------------------------------------------------------
inline Reflex::Reverse_Type_Iterator
Reflex::TypeBase::TemplateArgument_REnd() const {
//-------------------------------------------------------------------------------
return Dummy::TypeCont().rend();
}
//-------------------------------------------------------------------------------
inline Reflex::TypeTemplate
Reflex::TypeBase::TemplateFamily() const {
//-------------------------------------------------------------------------------
return Dummy::TypeTemplate();
}
//-------------------------------------------------------------------------------
inline const std::type_info&
Reflex::TypeBase::TypeInfo() const {
//-------------------------------------------------------------------------------
return *fTypeInfo;
}
//-------------------------------------------------------------------------------
inline void
Reflex::TypeBase::SetSize(size_t s) const {
//-------------------------------------------------------------------------------
fSize = s;
}
//-------------------------------------------------------------------------------
inline void
Reflex::TypeBase::SetTypeInfo(const std::type_info& ti) const {
//-------------------------------------------------------------------------------
fTypeInfo = &ti;
}
#endif // Reflex_TypeBase
|