HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PackedFolders Class Reference

Packed Folder Structure. More...

#include <GU_PackedFolders.h>

Classes

struct  EditInfo
 Simple struct holding the args for the remove and insert operations. More...
 
class  EditOperations
 Accumulate edit operations in a block. More...
 
class  FileInfo
 Class representing a file in the file map. More...
 

Public Member Functions

 GU_PackedFolders ()
 Construct a folder structure with its own detail. More...
 
 GU_PackedFolders (GU_DetailHandle &d, bool reuse_detail_ids=false, bool mark_existing=true)
 
 ~GU_PackedFolders ()=default
 
bool setFileProperties (const UT_StringRef &path, bool treat_as_folder, bool visible)
 
void replaceDetail (GU_DetailHandle &d)
 Rebuild file map over the given detail, holding references to it. More...
 
void updatePath (const UT_StringRef &path_str)
 Update the chain of packed primitives up the path to the root detail. More...
 
bool buildPath (const UT_StringRef &path_str)
 
bool insert (const UT_StringRef &path, const GU_ConstDetailHandle &d, bool pack=true, bool is_folder=false, bool is_visible=true)
 
bool remove (const UT_StringRef &path_str)
 
void merge (const GU_PackedFoldersRO &src_folders, const UT_StringRef &pattern)
 
bool edit (EditOperations &o)
 
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. More...
 
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. More...
 
void touch (const UT_StringRef &path, bool and_children=false)
 Sets touch flag on a given file & its children if and_children is true. More...
 
void touchFolders (const UT_StringRef &path_str)
 Mark all folders in the path given as touched. More...
 
void removeStale (const GU_PackedFolders *backup=nullptr)
 
bool isFolder (const UT_StringRef &path) const
 
const GU_PackedFolders::FileInfofindFile (const UT_StringRef &path) const
 
void findChildren (UT_Array< const GU_PackedFolders::FileInfo * > &out, const UT_StringRef &path) const
 
bool findFilesByPattern (UT_Array< const GU_PackedFolders::FileInfo * > &out, const UT_StringRef &pattern_str, bool sorted, UT_StringHolder &error) const
 
bool verify () const
 
UT_StringHolder getTopoFormat () const
 Returns a string representing the topology of the whole. More...
 
 GU_PackedFolders (const GU_PackedFolders &src)
 
GU_PackedFoldersoperator= (const GU_PackedFolders &src)
 

Static Public Member Functions

static bool treatAsFolder (const GU_PrimPacked *pack)
 Get and set treatasfolder intrinsic on a packed prim. More...
 
static void setTreatAsFolder (GU_PrimPacked *pack, bool b)
 
static bool isPrimVisible (const GA_Primitive *prim)
 Return whether the given primitive is in _3d_hidden_primitives. More...
 
static const GU_PrimPackedgetPackedFromDetail (const GU_Detail *gdp)
 
static bool updatePackedGeometry (GU_DetailHandle packed_gdh, GU_ConstDetailHandle gdh, const UT_StringRef &path)
 
static void splitFirstDirectory (UT_WorkBuffer &path, UT_WorkBuffer &out)
 
static void splitLastDirectory (UT_WorkBuffer &path, UT_WorkBuffer &out)
 
static void splitFileName (const UT_StringRef &label, UT_WorkBuffer &name, UT_WorkBuffer &type)
 
static void splitFilePath (const UT_StringRef &path, UT_Array< UT_StringHolder > &file_names)
 
static bool contains (GU_ConstDetailHandle gdh, const UT_StringRef &path, GA_OffsetArray *offsets=nullptr)
 
static bool contains (GU_ConstDetailHandle gdh, const UT_Array< UT_StringHolder > &file_names, GA_OffsetArray *offsets=nullptr)
 

Detailed Description

Packed Folder Structure.

Definition at line 219 of file GU_PackedFolders.h.

Constructor & Destructor Documentation

GU_PackedFolders::GU_PackedFolders ( )

Construct a folder structure with its own detail.

GU_PackedFolders::GU_PackedFolders ( GU_DetailHandle d,
bool  reuse_detail_ids = false,
bool  mark_existing = true 
)
explicit

Construct and build the map over the given detail, holding references to it Sets the Existing flag on existing paths. This affects the removeStale() behavior. Use mark_existing=true if you want to keep existing details as is and only modify the touched paths. Use mark_existing=false if you want to delete existing details that aren't touched

GU_PackedFolders::~GU_PackedFolders ( )
default
GU_PackedFolders::GU_PackedFolders ( const GU_PackedFolders src)
inline

Copy geometry and hierarchy from another GU_PackedFolders

Definition at line 389 of file GU_PackedFolders.h.

Member Function Documentation

bool GU_PackedFolders::buildPath ( const UT_StringRef path_str)

Build a path of folders if it does not exist already. Returns true if successful; fails if a file in path_str exists and is not a folder

void GU_PackedFolders::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.

static bool GU_PackedFolders::contains ( GU_ConstDetailHandle  gdh,
const UT_StringRef path,
GA_OffsetArray offsets = nullptr 
)
static

Returns whether the geometry contains a packed folder geometry with the given path.

static bool GU_PackedFolders::contains ( GU_ConstDetailHandle  gdh,
const UT_Array< UT_StringHolder > &  file_names,
GA_OffsetArray offsets = nullptr 
)
static

Returns whether the geometry contains a packed folder geometry with the given path.

bool GU_PackedFolders::edit ( EditOperations o)

Perform multiple insert/remove/move operations in a single step. Returns true if all the operations succeeded. o.myOps[i].myRet has the return status of individual edit operations. Note: GU_PackedFolders::FileInfo* can become invalid when rebuildMap() is called and it is likely to happen after doing many operations. You'll have to call the find() methods again.

void GU_PackedFolders::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 Note: GU_PackedFolders::FileInfo* can become invalid when rebuildMap() is called. It can happen when calling insert() or setFileProperties()

const GU_PackedFolders::FileInfo* GU_PackedFolders::findFile ( const UT_StringRef path) const

Get file access for read; returns nullptr if file does not exist Note: GU_PackedFolders::FileInfo* can become invalid when rebuildMap() is called. It can happen when calling insert() or setFileProperties()

bool GU_PackedFolders::findFilesByPattern ( UT_Array< const GU_PackedFolders::FileInfo * > &  out,
const UT_StringRef pattern_str,
bool  sorted,
UT_StringHolder error 
) const

Fill array with files which path the given apex syntax pattern; returns false on bad pattern_str

Parameters
sortedSorts the output list by file path. If disabled, the list is in an arbitrary order. Note: GU_PackedFolders::FileInfo* can become invalid when rebuildMap() is called. It can happen when calling insert() or setFileProperties()
static const GU_PrimPacked* GU_PackedFolders::getPackedFromDetail ( const GU_Detail gdp)
static

Return packed prim if the detail is a single, packed object; return null if not

UT_StringHolder GU_PackedFolders::getTopoFormat ( ) const

Returns a string representing the topology of the whole.

bool GU_PackedFolders::insert ( const UT_StringRef path,
const GU_ConstDetailHandle d,
bool  pack = true,
bool  is_folder = false,
bool  is_visible = true 
)

Insert/replace a file at the given path, creating the path if it does not exist. If pack is true, pack d before adding to the folder. If is_folder is true, set the treatasfolder intrinsic on the inserted file. Returns true if successful; fails if it can't create the path to the file Note: GU_PackedFolders::FileInfo* can become invalid after call insert() You'll have to call the find() methods again.

bool GU_PackedFolders::isFolder ( const UT_StringRef path) const

Check if file at given path is a folder; returns false if file does not exist

static bool GU_PackedFolders::isPrimVisible ( const GA_Primitive prim)
static

Return whether the given primitive is in _3d_hidden_primitives.

void GU_PackedFolders::merge ( const GU_PackedFoldersRO src_folders,
const UT_StringRef pattern 
)

Merges the contents of 'src_folders' into this folder structure, filtered by the specified file pattern. Note: GU_PackedFolders::FileInfo* can become invalid after call insert() You'll have to call the find() methods again.

GU_PackedFolders& GU_PackedFolders::operator= ( const GU_PackedFolders src)

Copy geometry and hierarchy from another GU_PackedFolders

bool GU_PackedFolders::remove ( const UT_StringRef path_str)

Remove a file or folder at the given path. Returns true if successful; fails if the given path is the root "/" or doesn't exist.

void GU_PackedFolders::removeStale ( const GU_PackedFolders backup = nullptr)

Removes stale files which are flagged as untouched. Files flagged existing if found by replaceDetail()/rebuildMap() are protected. If backup is provided, files which are untouched, modified, and existing will be replaced by the copy in backup. Files are marked modified if created/replaced by insert().

void GU_PackedFolders::replaceDetail ( GU_DetailHandle d)

Rebuild file map over the given detail, holding references to it.

bool GU_PackedFolders::setFileProperties ( const UT_StringRef path,
bool  treat_as_folder,
bool  visible 
)

Helper method to set the properties on an existing file Note: GU_PackedFolders::FileInfo* can become invalid after calling setFileProperties(). You'll have to call the find() methods again.

void GU_PackedFolders::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.

static void GU_PackedFolders::setTreatAsFolder ( GU_PrimPacked pack,
bool  b 
)
static
static void GU_PackedFolders::splitFileName ( const UT_StringRef label,
UT_WorkBuffer name,
UT_WorkBuffer type 
)
static

Path and name processing functions

static void GU_PackedFolders::splitFilePath ( const UT_StringRef path,
UT_Array< UT_StringHolder > &  file_names 
)
static

Path and name processing functions

static void GU_PackedFolders::splitFirstDirectory ( UT_WorkBuffer path,
UT_WorkBuffer out 
)
static

Path and name processing functions

static void GU_PackedFolders::splitLastDirectory ( UT_WorkBuffer path,
UT_WorkBuffer out 
)
static

Path and name processing functions

void GU_PackedFolders::touch ( const UT_StringRef path,
bool  and_children = false 
)

Sets touch flag on a given file & its children if and_children is true.

void GU_PackedFolders::touchFolders ( const UT_StringRef path_str)

Mark all folders in the path given as touched.

static bool GU_PackedFolders::treatAsFolder ( const GU_PrimPacked pack)
static

Get and set treatasfolder intrinsic on a packed prim.

static bool GU_PackedFolders::updatePackedGeometry ( GU_DetailHandle  packed_gdh,
GU_ConstDetailHandle  gdh,
const UT_StringRef path 
)
static

Updates the packed geometry at the given path. If no geometry exists at the given path, the geometry will not be added. Returns whether the geometry was successfully updated.

void GU_PackedFolders::updatePath ( const UT_StringRef path_str)

Update the chain of packed primitives up the path to the root detail.

bool GU_PackedFolders::verify ( ) const

Verifies packed primitive implementation pointers. Only does something on Windows debug builds.


The documentation for this class was generated from the following file: