11 #ifndef __GU_PackedFolders__
12 #define __GU_PackedFolders__
42 return std::holds_alternative<std::monostate>(myParentPrim);
46 return std::holds_alternative<const GU_PrimPacked *>(myParentPrim);
50 return std::holds_alternative<GA_Range>(myParentPrim);
58 return std::get<const GU_PrimPacked *>(myParentPrim);
76 return std::get<GA_Range>(myParentPrim);
82 bool treatAsFolder()
const;
87 return (myPath ==
"/" || treatAsFolder());
121 std::variant<std::monostate, const GU_PrimPacked *, GA_Range> myParentPrim;
126 bool myExisting =
false;
127 bool myModified =
false;
128 bool myTouched =
false;
129 bool myCleared =
false;
130 bool myVisible =
true;
191 FileInfo &rootFileInfo();
192 const FileInfo &rootFileInfo()
const;
222 return std::holds_alternative<std::monostate>(myParentPrim);
226 return std::holds_alternative<GU_PrimPacked *>(myParentPrim);
230 return std::holds_alternative<GA_Range>(myParentPrim);
238 return std::get<GU_PrimPacked *>(myParentPrim);
242 return std::get<GU_PrimPacked *>(myParentPrim);
250 auto *pp_prim = std::get_if<GU_PrimPacked *>(&myParentPrim);
251 return pp_prim ? *pp_prim :
nullptr;
255 auto *pp_prim = std::get_if<GU_PrimPacked *>(&myParentPrim);
256 return pp_prim ? *pp_prim :
nullptr;
264 return std::get<GA_Range>(myParentPrim);
268 return std::get<GA_Range>(myParentPrim);
283 return myPath ==
"/" || treatAsFolder();
290 return primGdh().castAwayConst();
296 if (myPrimGdh.isValid())
303 if (getIfParentPrim())
305 parentPrim()->unpack(*new_gdh.
gdpNC());
341 std::variant<std::monostate, GU_PrimPacked *, GA_Range> myParentPrim;
346 bool myExisting =
false;
347 bool myModified =
false;
348 bool myTouched =
false;
349 bool myCleared =
false;
350 bool myVisible =
true;
415 bool is_folder =
false,
416 bool is_visible =
true);
429 bool and_children =
false);
437 bool and_children =
false);
481 FileInfo &rootFileInfo();
482 const FileInfo &rootFileInfo()
const;
489 bool mark_existing =
true,
bool reuse_detail_ids=
false);
505 template <
typename T>
506 struct DefaultClearer;
520 static const bool clearNeedsDestruction =
true;
535 static const bool clearNeedsDestruction =
true;
void findChildren(UT_Array< const GU_PackedFolders::FileInfo * > &out, const UT_StringRef &path) const
Fill array with the children of this file at path, if it exists.
bool isFolder(const UT_StringRef &path) const
static bool treatAsFolder(const GU_PrimPacked *pack)
Get and set treatasfolder intrinsic on a packed prim.
static void setTreatAsFolder(GU_PrimPacked *pack, bool b)
GLuint GLsizei const GLchar * label
GU_PackedFoldersRO(const GU_PackedFoldersRO &src)
const GU_ConstDetailHandle & primGdh() const
bool treatAsFolder() const
~GU_PackedFolders()=default
UT_StringHolder getTopoFormat() const
Returns a string representing the topology of the whole.
bool isParentEmpty() const
GLsizei const GLchar *const * path
GU_PrimPacked * getIfParentPrim()
const GU_PrimPacked * getIfParentPrim() const
void replaceDetail(const GU_DetailHandle &d)
Rebuild file map over the given detail, holding references to it.
const GA_Range & parentRange() const
GU_PackedFolders(const GU_PackedFolders &src)
static void clear(GU_PackedFolders::FileInfo &v)
Read-Only Packed Folder Structure.
void updatePath(const UT_StringRef &path_str)
Update the chain of packed primitives up the path to the root detail.
UT_StringHolder getTopoFormat() const
Returns a string representing the topology of the whole.
void removeStale(const GU_PackedFolders *backup=nullptr)
bool buildPath(const UT_StringRef &path_str)
OIIO_FORCEINLINE vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
bool isParentRange() const
static bool isPrimVisible(const GA_Primitive *prim)
Return whether the given primitive is in _3d_hidden_primitives.
Class representing a file in the file map.
const UT_StringHolder & path() const
Path that this file represents.
bool setFileProperties(const UT_StringRef &path, bool treat_as_folder, bool visible)
Helper method to set the properties on an existing file.
bool isParentPrim() const
void setPrimGdh(const GU_ConstDetailHandle &prim_gdh)
static void clearConstruct(GU_PackedFoldersRO::FileInfo *p)
A range of elements in an index-map.
static void splitFileName(const UT_StringRef &label, UT_WorkBuffer &name, UT_WorkBuffer &type)
void allocateAndSet(GU_Detail *gdp, bool own=true)
const GU_PackedFolders::FileInfo * findFile(const UT_StringRef &path) const
Get file access for read; returns nullptr if file does not exist.
bool isParentRange() const
GU_DetailHandle safePrimGdhNC()
bool findFilesByPattern(UT_Array< const GU_PackedFolders::FileInfo * > &out, const UT_StringRef &pattern_str, bool sorted, UT_StringHolder &error) const
static void clearConstruct(GU_PackedFolders::FileInfo *p)
GU_ConstDetailHandle primGdh() const
bool findFilesByPattern(UT_Array< const GU_PackedFoldersRO::FileInfo * > &out, const UT_StringRef &pattern_str, bool sorted, UT_StringHolder &error) const
void touch(const UT_StringRef &path, bool and_children=false)
Sets touch flag on a given file & its children if and_children is true.
const UT_StringHolder & path() const
Path that this file represents.
static void clear(GU_PackedFoldersRO::FileInfo &v)
void replaceDetail(GU_DetailHandle &d)
Rebuild file map over the given detail, holding references to it.
GLuint const GLchar * name
bool isParentPrim() const
void setFlags(const UT_StringRef &path, bool existing, bool modified, bool touched, bool and_children=false)
Set flags to true on a given file and if desired, its children.
GLboolean GLboolean GLboolean b
bool isFolder() const
Return true if we're the root or treatAsFolder()
static const GU_PrimPacked * getPackedFromDetail(const GU_Detail *gdp)
Class representing a file in the file map.
const GA_Range & parentRange() const
GU_PackedFoldersRO()
Construct a folder structure with its own detail.
const GU_PackedFoldersRO::FileInfo * findFile(const UT_StringRef &path) const
Get file access for read; returns nullptr if file does not exist.
static void splitFirstDirectory(UT_WorkBuffer &path, UT_WorkBuffer &out)
GU_PrimPacked * parentPrim()
const GU_PrimPacked * parentPrim() const
LeafData & operator=(const LeafData &)=delete
void findChildren(UT_Array< const GU_PackedFoldersRO::FileInfo * > &out, const UT_StringRef &path) const
Fill array with the children of this file at path, if it exists.
static void splitLastDirectory(UT_WorkBuffer &path, UT_WorkBuffer &out)
const GU_PrimPacked * getIfParentPrim() const
GU_PackedFoldersRO(const GU_DetailHandle &d)
bool treatAsFolder() const
const GU_PrimPacked * parentPrim() const
bool isParentEmpty() const
~GU_PackedFoldersRO()=default
bool isFolder() const
Return true if we're the root or treatAsFolder()
void clearFlags(const UT_StringRef &path, bool existing, bool modified, bool touched, bool and_children=false)
Clear flags to false on a given file and if desired, its children.
GU_PackedFolders()
Construct a folder structure with its own detail.
void touchFolders(const UT_StringRef &path_str)
Mark all folders in the path given as touched.
static bool isClear(const GU_PackedFolders::FileInfo &v)
bool isFolder(const UT_StringRef &path) const
static bool isClear(const GU_PackedFoldersRO::FileInfo &v)