本文整理汇总了C++中Operation::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Operation::getType方法的具体用法?C++ Operation::getType怎么用?C++ Operation::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOperation
DECLARE_EXPORT Operation* BufferProcure::getOperation() const
{
if (!oper)
{
Operation *o = Operation::find(PURCHASE_OPERATION);
if (!o)
{
// Create a new purchase operation
o = new OperationFixedTime();
o->setName(PURCHASE_OPERATION);
static_cast<OperationFixedTime*>(o)->setDuration(leadtime);
new FlowEnd(o, const_cast<BufferProcure*>(this), 1);
}
// Copy procurement parameters to the existing operation
if (o->getType() == *OperationFixedTime::metadata)
static_cast<OperationFixedTime*>(o)->setDuration(leadtime);
const_cast<BufferProcure*>(this)->oper = o;
o->setFence(getFence());
o->setSizeMaximum(getSizeMaximum());
o->setSizeMinimum(getSizeMinimum());
o->setSizeMultiple(getSizeMultiple());
if (!o->getLocation()) o->setLocation(getLocation());
o->setSource(getSource());
}
return oper;
}
示例2: findOrCreate
OperationItemSupplier* OperationItemSupplier::findOrCreate(
ItemSupplier* i, Buffer *b
)
{
if (!i || !b || !i->getSupplier())
throw LogicException(
"An OperationItemSupplier always needs to point to "
"a itemsupplier and a buffer"
);
stringstream o;
o << "Purchase " << b->getName() << " from " << i->getSupplier()->getName();
Operation *oper = Operation::find(o.str());
if (oper)
{
// Reuse existing operation
if (oper->getType() == *OperationItemSupplier::metadata)
return static_cast<OperationItemSupplier*>(oper);
else
throw DataException("Unexpected operation type for item supplier operation");
}
else
// Create new operation
return new OperationItemSupplier(i, b);
}
示例3: location_tmp
extern "C" PyObject* OperationItemSupplier::createOrder(
PyObject *self, PyObject *args, PyObject *kwdict
)
{
// Parse the Python arguments
PyObject* pylocation = NULL;
unsigned long id = 0;
const char* ref = NULL;
PyObject* pyitem = NULL;
PyObject* pysupplier = NULL;
double qty = 0;
PyObject* pystart = NULL;
PyObject* pyend = NULL;
const char* status = NULL;
const char* source = NULL;
static const char *kwlist[] = {
"location", "id", "reference", "item", "supplier", "quantity", "start",
"end", "status", "source", NULL
};
int ok = PyArg_ParseTupleAndKeywords(
args, kwdict, "|OkzOOdOOzz:createOrder", const_cast<char**>(kwlist),
&pylocation, &id, &ref, &pyitem, &pysupplier, &qty, &pystart,
&pyend, &status, &source
);
if (!ok)
return NULL;
Date start = pystart ? PythonData(pystart).getDate() : Date::infinitePast;
Date end = pyend ? PythonData(pyend).getDate() : Date::infinitePast;
// Validate all arguments
if (!pylocation || !pyitem)
{
PyErr_SetString(PythonDataException, "item and location arguments are mandatory");
return NULL;
}
PythonData location_tmp(pylocation);
if (!location_tmp.check(Location::metadata))
{
PyErr_SetString(PythonDataException, "location argument must be of type location");
return NULL;
}
PythonData item_tmp(pyitem);
if (!item_tmp.check(Item::metadata))
{
PyErr_SetString(PythonDataException, "item argument must be of type item");
return NULL;
}
PythonData supplier_tmp(pysupplier);
if (pysupplier && !supplier_tmp.check(Supplier::metadata))
{
PyErr_SetString(PythonDataException, "supplier argument must be of type supplier");
return NULL;
}
Item *item = static_cast<Item*>(item_tmp.getObject());
Location *location = static_cast<Location*>(location_tmp.getObject());
Supplier *supplier = pysupplier ? static_cast<Supplier*>(supplier_tmp.getObject()) : NULL;
// Find or create the destination buffer.
Buffer* destbuffer = NULL;
for (Buffer::iterator bufiter = Buffer::begin(); bufiter != Buffer::end(); ++bufiter)
{
if (bufiter->getLocation() == location && bufiter->getItem() == item)
{
if (destbuffer)
{
stringstream o;
o << "Multiple buffers found for item '" << item << "'' and location'" << location << "'";
throw DataException(o.str());
}
destbuffer = &*bufiter;
}
}
if (!destbuffer)
{
// Create the destination buffer
destbuffer = new BufferDefault();
stringstream o;
o << item << " @ " << location;
destbuffer->setName(o.str());
destbuffer->setItem(item);
destbuffer->setLocation(location);
}
// Look for a matching matching supplying operation on this buffer.
// Here we also trigger the creation of its producing operation, which
// contains the logic to build possible transfer operations.
Operation *oper = NULL;
Operation* prodOper = destbuffer->getProducingOperation();
if (prodOper && prodOper->getType() == *OperationItemSupplier::metadata)
{
if (supplier)
{
if (supplier->isMemberOf(static_cast<OperationItemSupplier*>(prodOper)->getItemSupplier()->getSupplier()))
oper = prodOper;
}
else
oper = prodOper;
}
else if (prodOper && prodOper->getType() == *OperationAlternate::metadata)
{
//.........这里部分代码省略.........