11 #ifndef __GU_PackedFolders__
12 #define __GU_PackedFolders__
39 return std::holds_alternative<std::monostate>(myParentPrim);
43 return std::holds_alternative<const GU_PrimPacked *>(myParentPrim);
47 return std::holds_alternative<GA_Range>(myParentPrim);
55 return std::get<const GU_PrimPacked *>(myParentPrim);
73 return std::get<GA_Range>(myParentPrim);
79 bool treatAsFolder()
const;
84 return (myPath ==
"/" || treatAsFolder());
118 std::variant<std::monostate, const GU_PrimPacked *, GA_Range> myParentPrim;
123 bool myExisting =
false;
124 bool myModified =
false;
125 bool myTouched =
false;
126 bool myCleared =
false;
127 bool myVisible =
true;
178 FileInfo &rootFileInfo();
179 const FileInfo &rootFileInfo()
const;
204 return std::holds_alternative<std::monostate>(myParentPrim);
208 return std::holds_alternative<GU_PrimPacked *>(myParentPrim);
212 return std::holds_alternative<GA_Range>(myParentPrim);
220 return std::get<GU_PrimPacked *>(myParentPrim);
224 return std::get<GU_PrimPacked *>(myParentPrim);
232 auto *pp_prim = std::get_if<GU_PrimPacked *>(&myParentPrim);
233 return pp_prim ? *pp_prim :
nullptr;
237 auto *pp_prim = std::get_if<GU_PrimPacked *>(&myParentPrim);
238 return pp_prim ? *pp_prim :
nullptr;
246 return std::get<GA_Range>(myParentPrim);
250 return std::get<GA_Range>(myParentPrim);
265 return myPath ==
"/" || treatAsFolder();
272 return primGdh().castAwayConst();
277 if (myPrimGdh.isValid())
284 if (getIfParentPrim())
286 parentPrim()->unpack(*new_gdh.
gdpNC());
322 std::variant<std::monostate, GU_PrimPacked *, GA_Range> myParentPrim;
327 bool myExisting =
false;
328 bool myModified =
false;
329 bool myTouched =
false;
330 bool myCleared =
false;
331 bool myVisible =
true;
399 bool is_folder =
false,
400 bool is_visible =
true);
413 bool and_children =
false);
421 bool and_children =
false);
459 FileInfo &rootFileInfo();
460 const FileInfo &rootFileInfo()
const;
467 bool mark_existing =
true);
483 template <
typename T>
484 struct DefaultClearer;
498 static const bool clearNeedsDestruction =
true;
513 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
bool isParentEmpty() const
GLsizei const GLchar *const * path
GU_PrimPacked * getIfParentPrim()
GU_PackedFolders & operator=(const GU_PackedFolders &src)
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.
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()
GU_PackedFolders(GU_DetailHandle &d)
static void clearConstruct(GU_PackedFolders::FileInfo *p)
GU_ConstDetailHandle primGdh() 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
bool findFilesByPattern(UT_Array< const GU_PackedFolders::FileInfo * > &out, const UT_StringRef &pattern_str, UT_StringHolder &error) 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
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.
GU_PackedFoldersRO & operator=(const GU_PackedFoldersRO &src)
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
bool findFilesByPattern(UT_Array< const GU_PackedFoldersRO::FileInfo * > &out, const UT_StringRef &pattern_str, UT_StringHolder &error) const
static bool isClear(const GU_PackedFoldersRO::FileInfo &v)