FCF 2.0 development in progress...
> > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

fcf::ResolveData class

Type:
class fcf::ResolveData

Package: fcfBasis

File: bits/PartSpecifier/ResolveSpecifierDefinition.hpp

Available from version: 1.0.1

The structure describing the information returned by the fcf::ResolveSpecifier specifier. Structure containing resolved data, its type index, and invariance information.

fcf::ResolveData is a data carrier used by the framework during runtime resolution operations (such as fcf::ResolveSpecifier). It encapsulates the raw pointer to the resolved data, the unique type index of that data, and a flag indicating whether the data is invariant.

Properties
void* data
- A pointer to the data stored in the object.
fcf::TypeIndex typeIndex
- Integer value ​​of a type index.
bool invariant
- The flag indicating whether an object can store different types of data

Example:

#include <iostream> // Define an implementation macro to include the implementation section in header files #define FCF_BASIS_IMPLEMENTATION #include <fcfBasis/basis.hpp> // 1. Define a custom type that we want to resolve struct Person { int age; }; // Register the type in the fcf system FCF_TYPE_REGISTRATION(Person, "Person", 0); // 2. Implement a specifier that returns fcf::ResolveData. // The fcf::ResolveSpecifier is designed to return a fcf::ResolveData structure // which tells the framework where the underlying data is and what its type is. namespace fcf { template<> struct Type<Person, ResolveSpecifier> : public TypeImpl<Person, ResolveSpecifier> { enum { invariantValue = false }; inline void operator()(Person* a_object, void** a_dstData, fcf::TypeIndex* a_dstTypeIndex) const { *a_dstData = &a_object->age; *a_dstTypeIndex = fcf::Type<int>().index(); } }; } // 3. Bind the specifier implementation to our type FCF_SPECIFIER_REGISTRATION(Person, fcf::ResolveSpecifier); int main() { // Create an instance of our custom type Person data{42}; std::cout << "=== [1] Manual fcf::ResolveData Simulation ===" << std::endl; { // 4. Retrieve the call function for the fcf::ResolveSpecifier // This function is what the framework uses to perform the resolution fcf::ResolveSpecifier::CallType resolveFunc = fcf::Type<Person>().specifierCall<fcf::ResolveSpecifier>(0); if (resolveFunc) { // The result of the call is the ResolveData object fcf::ResolveData rd = resolveFunc(&data); std::cout << "Resolution successful!" << std::endl; std::cout << "Resolved Type Index: 0x" << std::hex << rd.typeIndex << std::dec << std::endl; std::cout << "Is Invariant: " << (rd.invariant ? "Yes" : "No") << std::endl; // Use the pointer from data to access the value int resolvedValue = *static_cast<int*>(rd.data); std::cout << "Resolved Value: " << resolvedValue << std::endl; } else { std::cout << "Specifier not found!" << std::endl; } } return 0; }

Output:

=== [1] Manual ResolveData Simulation === Resolution successful! Resolved Type Index: 0x5 Is Invariant: No Resolved Value: 42