Skip to content

Reflection

29thnight edited this page Nov 28, 2025 · 1 revision

Reflection 헤더 모음

간단 설명: 리플렉션 매크로/유틸/타입/레지스트리/GUI/직렬화/벡터 지원 등 리플렉션 시스템 구성 헤더들.

  • Reflection.hpp: 매크로 헤더 포함
  • ReflectionMecro.h: 클래스/상속/스크립트 리플렉션 매크로 정의, 생성 본문 매크로
  • ReflectionType.h: Type/Property/Method 구조와 벡터 이터레이터, 컨셉 정의
  • ReflectionFunction.h: 타입 등록/검색, 프로퍼티/메서드 생성, 메서드 호출, Undo 커맨드 생성
  • ReflectionRegister.h: 타입/열거/팩토리/캐스터/Undo 매니저 레지스트리와 스코프 관리, 초기화/정리
  • ReflectionImGuiHelper.h: ImGui 기반 프로퍼티/메서드 편집 GUI, 드래그드롭, 다양한 타입 위젯 처리
  • ReflectionYml.h: YAML 직렬화/역직렬화/프리팹 패치 로직
  • ReflectionVectorFactory.h: std::vector<T> 동적 생성 레지스트리
  • ReflectionVectorInvoker.h: YAML 노드→벡터 역직렬화 핸들러 레지스트리
  • ReflectionVectorMapper.h: 템플릿 매퍼로 벡터 요소 역직렬화 구현

헤더툴 기반 사용 예제 (SoundComponent)

실사용 파일 SoundComponent.h의 커스텀 속성/메서드 문법과 자동생성 파일 SoundComponent.generated.h를 통해 리플렉션을 구성합니다.

  1. 사용자 헤더 정의 예 (SoundComponent.h 발췌)
  • 클래스 상단에 자동생성 헤더 포함: #include "SoundComponent.generated.h"
  • 클래스 내부에 자동생성 매크로 배치: ReflectSoundComponent
  • 직렬화 속성: [[Serializable(Inheritance:Component)]], 본문: GENERATED_BODY(SoundComponent)
  • 리플렉션 대상 필드에 [[Property]] 부여, 메서드에 [[Method]] 부여
    • 예) [[Property]] std::string clipKey;, [[Property]] ChannelType bus;, [[Property]] float volume/pitch;, [[Property]] bool loop/playOnStart/spatial/useReverbSend;
    • 예) [[Method]] void Play();, [[Method]] void Stop();, [[Method]] void Pause(bool);, [[Method]] bool IsPlaying();, [[Method]] void PlayOneShot();
  1. 헤더툴 자동생성 예 (SoundComponent.generated.h)
  • 매크로 ReflectSoundComponentReflectionFieldInheritance(SoundComponent, Component)Reflect()를 구현하고, PropertyField/MethodField에 지정된 항목을 나열합니다.
  • 생성 결과는 필요에 따라 PropertyOnlyInheritance 또는 PropertyAndMethodInheritance 형태로 부모 Component를 이어받습니다.

생성 매크로 구조(예시):

  • ReflectionFieldInheritance(SoundComponent, Component)
  • PropertyField({ meta_property(clipKey) ... })
  • MethodField({ meta_method(Play), meta_method(Stop), ... })
  • FieldEnd(SoundComponent, PropertyAndMethodInheritance)
  1. 런타임 등록/사용
  • 초기화에서 Meta::Register<T>() 또는 AUTO_REGISTER_CLASS(T) 사용
  • GUI/직렬화 사용:
    • GUI: Meta::DrawObject(instance, T::Reflect())로 ImGui 인스펙터 생성(슬라이더/체크박스/텍스트 등 자동 매핑)
    • YAML: Meta::Serialize(instance) / Meta::Deserialize(instance, node)로 저장/로드
  1. 포인터/벡터/열거 처리
  • 포인터 필드는 타입명 기반으로 중첩 DrawObject/Serialize 처리
  • 벡터 필드는 VectorFactory/Invoker로 요소 생성 및 역직렬화
  • 열거형은 AUTO_REGISTER_ENUM(EnumType) 등록 후 콤보 UI/직렬화 지원

위와 같이 [[Property]]/[[Method]]가 붙은 항목은 자동으로 리플렉션 시스템에 연결되어 에디터/직렬화/스크립트 상호작용에 활용됩니다.

CreatorEngine

API Docs

API Reference
Main
PhysicsSystem
RenderEngine
ScriptBinder
Utility_Framework

etc

Clone this wiki locally