Appleseed: Frame::write() 및 Frame::archive()λ₯Ό λ³„λ„μ˜ 클래슀둜 이동

에 λ§Œλ“  2011λ…„ 10μ›” 17일  Β·  10μ½”λ©˜νŠΈ  Β·  좜처: appleseedhq/appleseed

예λ₯Ό λ“€μ–΄ renderer::FrameWriter 및 renderer::FrameArchiver .

Refactoring Good First Issue

λͺ¨λ“  10 λŒ“κΈ€

λ‚˜λŠ” 이것에 λŒ€ν•΄ 일할 것이닀

μ™œ κ·Έλ ‡κ²Œ ν•΄μ•Ό ν•©λ‹ˆκΉŒ? 이 두 클래슀의 μ˜λ„λŠ” λ¬΄μ—‡μž…λ‹ˆκΉŒ? κ·Έλƒ₯ κΆκΈˆν•©λ‹ˆλ‹€.

μ•ˆλ“œλ ˆ: ν›Œλ₯­ν•΄!

Dorian: 그것은 단지 λ¦¬νŒ©ν† λ§μΌ λΏμž…λ‹ˆλ‹€. 이미지 μž‘μ„± μ½”λ“œλŠ” renderer::Frame μ—”ν‹°ν‹°μ˜ κ΅¬ν˜„μ— λ§Žμ€ ν˜Όλž€μ„ μΆ”κ°€ν•©λ‹ˆλ‹€.

μ•Œμ•˜μ–΄ κ³ λ§ˆμ›Œ! :)

λˆ„κ΅°κ°€μ΄ μž‘μ—…μ„ μ‹œμž‘ ν–ˆμŠ΅λ‹ˆκΉŒ? λ‚΄κ°€ ν•΄λ³Ό 수 μžˆμ„κΉŒ?

κΈ€μŽ„, AndrΓ©λŠ” 이미 그것에 μžˆλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. AndrΓ©, 아직 μž‘μ—… μ€‘μΈκ°€μš”?

λ„€, 주말에 λ°”λΉ μ„œ μ£„μ†‘ν•©λ‹ˆλ‹€λ§Œ ν•΄λ³΄κ² μŠ΅λ‹ˆλ‹€!

이에 λŒ€ν•œ μ‰˜ 클래슀λ₯Ό μ œκ³΅ν•  수 μžˆμŠ΅λ‹ˆκΉŒ? μ½”λ“œμ˜ 일뢀λ₯Ό μ΄ν•΄ν•˜λŠ” 데 λ¬Έμ œκ°€ 있으며 이에 λŒ€ν•œ λ¬Έμ„œλ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€. 이것은 무엇을 ν•©λ‹ˆκΉŒ:

namespace
{
    const UniqueID g_class_uid = new_guid();
}

UniqueID Frame::get_class_uid()
{
    return g_class_uid;
}

λ‚΄κ°€ 이것을 μ˜¬λ°”λ₯΄κ²Œ μ–»λŠ”λ‹€λ©΄ λ‚˜λŠ”μ΄ κΈ°λŠ₯을 이동할 κ²ƒμž…λ‹ˆλ‹€ :

bool Frame::archive(
    const char*         directory,
    char**              output_path) const
{
    assert(directory);

    // Construct the name of the image file.
    const string filename =
        "autosave." + get_time_stamp_string() + ".exr";

    // Construct the path to the image file.
    const string file_path = (filesystem::path(directory) / filename).string();

    // Return the path to the image file.
    if (output_path)
        *output_path = duplicate_string(file_path.c_str());

    Image transformed_image(*impl->m_image);
    transform_to_output_color_space(transformed_image);

    return
        write_image(
            file_path.c_str(),
            transformed_image,
            ImageAttributes::create_default_attributes());
}

FrameWriter 클래슀둜. 클래슀 μž‘μ„±μ„ μ‹œμž‘ν•˜λŠ” 방법을 잘 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€. λ‹€μŒκ³Ό 같이 ν‘œμ‹œλ˜μ–΄μ•Ό ν•©λ‹ˆλ‹€.

//
// This source file is part of appleseed.
// Visit http://appleseedhq.net/ for additional information and resources.

//includes

//using namespaces

namespace renderer
{

FrameArchiver::archive(...)
{
//code from Frame::archive
}

}   // namespace renderer

κ°μ‚¬ν•©λ‹ˆλ‹€. ν”„λ‘œκ·Έλž˜λ°μ„ μ‹œμž‘ν•˜λ €λ©΄ ν‚₯μŠ€νƒ€νŠΈκ°€ ν•„μš”ν•©λ‹ˆλ‹€.

λ„€, 기본적으둜 κ·Έλ ‡μŠ΅λ‹ˆλ‹€. 두 개의 μƒˆ 파일 쌍( framewriter.{h,cpp} 및 framearchiver.{h,cpp} ) λ˜λŠ” ν•œ 쌍( framewriter.{h,cpp} )이 μΆ©λΆ„ν•˜λ‹€κ³  μƒκ°λ˜λ©΄ νŒŒμΌμ— μΆ”κ°€ν•΄μ•Ό ν•©λ‹ˆλ‹€. CMakeLists.txt νŒŒμΌμ„ λ§Œλ“€κ³  μ½”λ“œλ₯Ό 이 μƒˆ 파일둜 μ΄λ™ν•©λ‹ˆλ‹€.

μ§€κΈˆ:

namespace
{
    const UniqueID g_class_uid = new_guid();
}

μ΄λ ‡κ²Œ ν•˜λ©΄ 이 νŒŒμΌμ— 둜컬인 μƒˆ 고유 IDκ°€ μƒμ„±λ©λ‹ˆλ‹€. 이 IDλŠ” "ν”„λ ˆμž„" μ—”ν„°ν‹° 클래슀λ₯Ό κ³ μœ ν•˜κ²Œ μ‹λ³„ν•˜λŠ” 데 μ‚¬μš©λ©λ‹ˆλ‹€. "Frame" ν΄λž˜μŠ€μ— ν•΄λ‹Ήν•˜λŠ” 클래슀 IDλŠ” λ‹€μŒ 정적 λ©”μ„œλ“œλ₯Ό 톡해 μ•‘μ„ΈμŠ€ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

UniqueID Frame::get_class_uid()
{
    return g_class_uid;
}

FrameWriter ν΄λž˜μŠ€λŠ” μ—”ν‹°ν‹° ν΄λž˜μŠ€κ°€ μ•„λ‹ˆλΌ 일반 ν΄λž˜μŠ€μ΄λ―€λ‘œ 이 쀑 μ–΄λŠ 것도 ν•„μš”ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

이 λ¬Έμ œλŠ” λ‹€μ‹œ μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰