#include "GU_PackedSharedData.h"
using namespace HDK_Sample;
namespace
{
static const UT_StringRef theSharedIdentifier =
"hdk:shareddata";
using SharedInfo = GU_PackedSharedData::SharedInfo;
{
public:
: myData(data)
, myKey(key)
{
}
~loadedSharedData() override
{
}
{
return myKey;
}
};
{
if (!date)
else
{
key.
sprintf(
"shdata:%p", date.get());
}
}
{
public:
PackedPrimFactory()
, theDefaultImpl(new GU_PackedSharedData())
{
registerIntrinsic(theDateStr,
StringHolderGetterCast(&GU_PackedSharedData::creationDate));
registerIntrinsic(theHostStr,
StringHolderGetterCast(&GU_PackedSharedData::creationHost));
}
~PackedPrimFactory() override {}
{
return theDefaultImpl;
}
{
return new GU_PackedSharedData();
}
const char *key,
bool isDelayedLoad) const override
{
return nullptr;
auto d = UTmakeShared<SharedInfo>();
{
auto date = map->
get(theDateStr);
auto host = map->
get(theHostStr);
d->myTimeStamp = *date->getStringHolder();
d->myHostname = *host->getStringHolder();
}
return new loadedSharedData(d, key);
}
};
static PackedPrimFactory *theFactory = NULL;
boxGeometry()
{
{
}
}
}
GU_PackedSharedData::SharedInfo::SharedInfo()
{
myHostname = hostname;
}
GU_PackedSharedData::GU_PackedSharedData()
, mySharedHandle()
, mySharedInfo(new SharedInfo)
{
}
GU_PackedSharedData::GU_PackedSharedData(
const GU_PackedSharedData &
src)
, mySharedHandle(src.mySharedHandle)
, mySharedInfo(src.mySharedInfo)
{
}
GU_PackedSharedData::~GU_PackedSharedData()
{
}
void
{
if (theFactory)
return;
theFactory = new PackedPrimFactory();
if (theFactory->isRegistered())
{
theTypeId = theFactory->typeDef().getId();
}
else
{
fprintf(stderr,
"Unable to register packed shared data from %s\n",
}
}
GU_PackedSharedData::getFactory() const
{
return theFactory;
}
{
return new GU_PackedSharedData(*this);
}
void
GU_PackedSharedData::clearData()
{
}
bool
GU_PackedSharedData::isValid() const
{
return true;
}
template <typename T>
void
GU_PackedSharedData::updateFrom(
const T &options,
const GA_LoadMap *loadmap)
{
if (loadmap && import(options, theSharedIdentifier, key))
{
"PackedSharedData", nullptr);
}
}
bool
{
options.
setOptionS(theSharedIdentifier, makeSharedDataKey(mySharedInfo));
return true;
}
bool
{
return true;
}
bool
{
return getBounds(box);
}
void
{
min = 0;
max = 0;
}
void
{
min = max = 0;
}
bool
{
unpackToDetail(destgdp, boxGeometry(), transform);
return true;
}
GU_PackedSharedData::getMemoryUsage(bool inclusive) const
{
int64 mem = inclusive ?
sizeof(*this) : 0;
mem += mySharedInfo->myTimeStamp.getMemoryUsage(true);
mem += mySharedInfo->myHostname.getMemoryUsage(true);
return mem;
}
void
GU_PackedSharedData::countMemory(
UT_MemoryCounter &counter,
bool inclusive)
const
{
{
size_t mem = inclusive ? sizeof(*this) : 0;
}
#if 0
mem += mySharedInfo->myTimeStamp.getMemoryUsage(true);
mem += mySharedInfo->myHostname.getMemoryUsage(true);
#endif
}
bool
GU_PackedSharedData::resolveSharedData() const
{
if (mySharedHandle)
{
const loadedSharedData *
data;
item = mySharedHandle->resolveSharedData(nullptr);
data = dynamic_cast<const loadedSharedData *>(item);
if (data)
{
mySharedInfo = data->myData;
}
else
{
return false;
}
mySharedHandle.reset();
}
return true;
}
bool
GU_PackedSharedData::saveSharedData(
{
bool ok = true;
resolveSharedData();
if (mySharedInfo)
{
auto &&key = makeSharedDataKey(mySharedInfo);
{
ok = ok && w.
jsonString(mySharedInfo->myTimeStamp);
ok = ok && w.
jsonString(mySharedInfo->myHostname);
}
}
return ok;
}
GU_PackedSharedData::creationDate(
const GU_PrimPacked *prim)
const
{
resolveSharedData();
return mySharedInfo->myTimeStamp;
}
GU_PackedSharedData::creationHost(
const GU_PrimPacked *prim)
const
{
resolveSharedData();
return mySharedInfo->myHostname;
}
void
{
GU_PackedSharedData::install(f);
}