本文整理汇总了C++中Package类的典型用法代码示例。如果您正苦于以下问题:C++ Package类的具体用法?C++ Package怎么用?C++ Package使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Package类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: depends
bool Package::PackDepend(const Package& p) const
{
bool depends(false);
Depend(p);
for(std::set<Package>::const_iterator it = m_Package->second.package.begin();
it != m_Package->second.package.end(); ++it)
{
p.PackDepend(*it);
}
for(std::set<Object>::const_iterator it = m_Package->second.object.begin();
it != m_Package->second.object.end(); ++it)
{
if(it->Depend(p))
{
//direct dependency
depends = true;
}
}
if(depends && Name() != p.Name())
{
std::clog << '"' << fs::basename(fs::path(Name()).leaf()) << "\" -> \""
<< fs::basename(fs::path(p.Name()).leaf()) << "\";" << std::endl;
}
return depends;
}
示例2: Package
int TcpProtocol::mysend(char *data, int len, int peer)
{
Package *message = new Package(2, peer, data);
int m = send(msocket, message->getbuf(), PACKAGE_SIZE, 0);
delete message;
return m;
}
示例3: FinishSqliteVFS
void PackageService::onFinish()
{
FinishSqliteVFS();
// Turn off all sticky flags - NO MERCY!
for (PackageNameMap::iterator itr = _linkedPackages.begin(), end = _linkedPackages.end(); itr != end; ++itr)
{
itr->second->_stayResident = false;
itr->second->_stayForCurrent = false;
itr->second->_stayForNext = false;
}
// And compact so that all packages get disposed
compact();
// If Something's remaining, we're in danger!
for (PackageNameMap::iterator itr = _linkedPackages.begin(), end = _linkedPackages.end(); itr != end; ++itr)
{
Package* pack = itr->second;
LOG(0, "*** Package '%s': still alive: %d usage, requires:\n", pack->getName().c_str(), pack->getUseCount());
if (pack->getRequiredList().empty())
LOG(0, " <none>\n");
else
pack->printDependancy(1);
}
// Terminate AsyncLoader
if (_asyncLoader)
{
_asyncLoader->Terminate();
}
safeDelete(_asyncLoader);
}
示例4: general_replica
int general_replica(Package package, struct HostEntity &destination) {
package.set_replicano(3);
string str = package.SerializeAsString();
// cout << "socket_replica--------1" << endl;
// cout << "socket_replica--------before makeConnForReplica sock = "<< destination.sock << endl;
int sock = makeConnForReplica(destination); //reusable sockets creation
// cout << "socket_replica--------after makeConnForReplica sock = "<< destination.sock << endl;
// int sock = makeClientSocket("localhost", 50009, true);
// cout << "socket_replica--------2, sock = " << sock << endl;
// generalSend(destination.host, destination.port, sock, str.c_str(), 1);
// cout << "socket_replica--------2, sock = " << sock << endl;
// generalSendTCP(sock, str.c_str());
generalSendTo(destination.host.c_str(), destination.port, sock, str.c_str(),
str.size(), TCP);
// cout << "socket_replica--------3" << endl;
void *buff_return = (void*) malloc(sizeof(int32_t));
// int r = d3_svr_recv(sock, buff_return, sizeof(int32_t), 0, &recv_addr);
// int r = generalReveiveTCP(sock, buff_return, sizeof buff_return, 0);
struct sockaddr_in recvAddr;
// int r =generalReceive(sock, buff_return, sizeof(int32_t), recvAddr, 0, TCP);
int r = 0;
// cout << "socket_replica--------4" << endl;
//connect (int socket, struct sockaddr *addr, size_t length)
if (r < 0) {
cerr << "general_replica: got bad news from relica: " << r << endl;
}
}
示例5: create
void SharedMemory::create(const char* name, Package& pkg)
{
shared_mem_name_ = name;
// Create a shared memory object
shm = ipc::shared_memory_object(ipc::open_or_create, shared_mem_name_.c_str(), ipc::read_write);
// Serialize the package specification (first to a buffer, because we do not know how big it is)
io::GrowingBuffer spec;
pkg.SerializeSpecification(spec);
// Set size: specification size + package size
shm.truncate(spec.size() + pkg.size());
// Map the specification region
mem_spec_ = ipc::mapped_region(shm, ipc::read_write, 0, spec.size());
// Map the data (pkg) region
mem_pkg_ = ipc::mapped_region(shm, ipc::read_write, spec.size(), pkg.size());
// Copy the package specification to the shared memory
spec.copyTo(mem_spec_.get_address());
// Map the package to the data address
pkg.mapTo(mem_pkg_.get_address());
}
示例6: AbstractHost
Controller::Controller(int serverSocket, bool displayStati) : AbstractHost(serverSocket), stdinWatcher(NULL), commands(NULL), lastSendPackageID(0), waitingForAck(false), maxCommandNameLength(0)
{
this->displayStati = displayStati;
std::cout<<std::endl;
std::cout<<" _ ._ _| _ ._ |_ _ "<<std::endl;
std::cout<<" \\/(_)| |(_|(/_| |_)(_)\\/"<<std::endl;
std::cout<<" / / "<<std::endl;
std::cout<<std::endl;
commands = new std::map<std::string, CommandParser*>();
parseSpecFile(configuration->retrieveAsPath("general","net-spec"));
if(maxCommandNameLength<4) { maxCommandNameLength = 4; } // for the case where the "help" command is the longest
commands->insert(std::make_pair("help", new HelpCommandParser(commands, maxCommandNameLength)));
// setup stdin read watcher and readline library
rl_attempted_completion_function = &Controller::completionCallback;
using_history();
stdinWatcher = new ev::io();
stdinWatcher->set<Controller, &Controller::stdinCallback>(this);
Package *initPackage;
if(displayStati)
{
initPackage = constructPackage("connection-management", "id", getNextPackageID().c_str(), "command", "initialize", "client-name", PROJECT_NAME, "client-version", PROJECT_VERSION, "can-display-stati", "", "interactive", "", "can-handle-requests", "", NULL);
}
else
{
initPackage = constructPackage("connection-management", "id", getNextPackageID().c_str(), "command", "initialize", "client-name", PROJECT_NAME, "client-version", PROJECT_VERSION, "interactive", "", "can-handle-requests", "", NULL);
}
lastSendPackageID = initPackage->getID();
waitingForAck = true;
sendPackageAndDelete(initPackage);
}
示例7: HB_insert
int32_t HB_insert(NoVoHT *map, Package &package) {
//int opt = package.operation();//opt not be used?
string value = package.SerializeAsString();
//int ret = db.set(package.virtualpath(), package_str); //virtualpath as key
// cout << "Insert to pmap...value = " << value << endl;
string key = package.virtualpath();
// cout<<"key:"<<key<<endl;
// cout<<"value:"<<value<<endl;
// cout<<"Insert: k-v ready. put..."<<endl;
int ret = map->put(key, value);
// cout << "end inserting, ret = " << ret << endl;
if (ret != 0) {
cerr << "insert error: ret = " << ret << endl;
return -3;
}
/*
cout << "String insted: " << package_str << endl;
*/
else
return 0;
}
示例8: in_ping_ACK
void Server::in_ping_ACK(Packet* p)
{
sf::Uint8 sortingId;
*p >> sortingId;
Package* pack = connection.getPacketNR(sortingId);
if (pack == 0)
{
cout << "Recieved ACK on a non-used package slot?" << endl;
return;
}
//ping doesnt use event ID so it should be empty
if (pack->getEventID() != NET_EVENT_ID::EMPTY)
{
cout << "Recieved ACK on WRONG package slot?" << endl;
return;
}
unsigned int oldStamp = pack->getTimeStamp();
unsigned int temp = clock();
oldStamp = temp - oldStamp;
cout << "Ping Confirmed. RTT: " << oldStamp << endl;
connection.successfulPing = true;
connection.clearPacketNR(sortingId);
}
示例9: architecures
void RepositoryProfile::addPackage ( const Package &package )
{
packages.insert ( package.packageName(), package );
// set the architecture for this package
packages[package.packageName() ].setArchitectures ( PackageMetaData::archStringList ( architecures() ) );
updatePackageStatus ( package.packageName() );
}
示例10: displaySplash
void MeshGame::initialize()
{
// Display the gameplay splash screen for at least 2.4 seconds.
displaySplash(this, &MeshGame::drawSplash, NULL, 2400L);
// Load font
_font = Font::create("res/arial40.gpb");
// Load mesh/scene from file
Package* pkg = Package::create("res/duck.gpb");
_scene = pkg->loadScene();
SAFE_RELEASE(pkg);
// Get the duck node
_modelNode = _scene->findNode("duck");
// Bind the material to the model
_modelNode->getModel()->setMaterial("res/duck.material");
// Find the light node
Node* lightNode = _scene->findNode("directionalLight1");
// Bind the light node's direction into duck's material.
_modelNode->getModel()->getMaterial()->getParameter("u_lightDirection")->bindValue(lightNode, &Node::getForwardVectorView);
}
示例11: HELIUM_ASSERT
const FilePath *Helium::Asset::GetAssetFileSystemPath()
{
HELIUM_ASSERT( !m_path.IsEmpty() );
FilePath filePath;
Asset *pSourceAsset = GetSourceAsset();
if (pSourceAsset)
{
Package *pPackage = Reflect::SafeCast<Package>( pSourceAsset->GetOwner() );
if ( pPackage )
{
PackageLoader *pLoader = pPackage->GetLoader();
HELIUM_ASSERT( pLoader->HasAssetFileState() );
if ( pLoader )
{
return &pLoader->GetAssetFileSystemPath( pSourceAsset->GetPath() );
}
}
}
return NULL;
}
示例12: notQueue
void* notQueue(void* args) {
Worker *worker = (Worker*) args;
string *st;
Package package;
while (ON) {
while (notifyq.size() > 0) {
pthread_mutex_lock(¬q_lock);
if (notifyq.size() > 0) {
try {
st = notifyq.front();
notifyq.pop();
} catch (exception& e) {
cout << "void* notifyq: " << e.what() << endl;
exit(1);
}
} else {
pthread_mutex_unlock(¬q_lock);
continue;
}
pthread_mutex_unlock(¬q_lock);
package.ParseFromString(*st);
delete st;
worker->update(package);
}
}
}
示例13: myhash
int Worker::zht_remove(string key) {
/*Package package;
package.set_virtualpath(key);
package.set_operation(2);
string str = package.SerializeAsString();
int index;
svrclient.str2Host(str, index);*/
int index = myhash(key.c_str(), svrclient.memberList.size());
if (index != selfIndex) {
Package package;
package.set_virtualpath(key);
package.set_operation(2);
string str = package.SerializeAsString();
pthread_mutex_lock(&msg_lock);
int ret = svrclient.remove(str);
pthread_mutex_unlock(&msg_lock);
return ret;
} else {
int ret = pmap->remove(key);
if (ret != 0) {
cerr << "DB Error: fail to remove :ret= " << ret << endl;
return -2;
} else
return 0; //succeed.
}
}
示例14: zht_insert
int Worker::zht_insert(string str) {
Package package;
package.ParseFromString(str);
package.set_operation(3);
str = package.SerializeAsString();
int index;
svrclient.str2Host(str, index);
if (index != selfIndex) { //cout << "NOOOOO..index = " << index << endl;
pthread_mutex_lock(&msg_lock);
int ret = svrclient.insert(str);
pthread_mutex_unlock(&msg_lock);
return ret;
} else {
string key = package.virtualpath(); //cout << "key = " << key << endl;
//pthread_mutex_lock(&zht_lock);
int ret = pmap->put(key, str);
//pthread_mutex_unlock(&zht_lock);
if (ret != 0) {
cerr << "insert error: key = " << key << " ret = " << ret << endl;
return -3;
} else
return 0;
}
}
示例15: OutcomPackage
OutcomePackage::OutcomePackage(const Package &xPackage) : OutcomPackage()
{
mHeaderSended = false;
mBodySended = false;
mFileSended = false;
mBody.open(QIODevice::WriteOnly);
QDataStream xBodyStream(&mBody);
xBodyStream.setVersion(QDataStream::Qt_4_7);
xBodyStream<<xPackage.getBodyFields();
mBody.close();
mFile.setFileName(xPackage.getAttachedFile());
QFileInfo xAttachedFileInfo(mFile);
mHeader.open(QIODevice::WriteOnly);
QDataStream xHeaderStream(&mHeader);
xHeaderStream.setVersion(QDataStream::Qt_4_7);
xHeaderStream<<qint64(0);//оставляем место для размера заголовка
xHeaderStream<<mBody.size();
xHeaderStream<<xAttachedFileInfo.fileName();
xHeaderStream<<mFile.size();
xHeaderStream.device()->seek(0);
xHeaderStream<<mHeader.size();
mHeader.close();
mBytesTottal = mHeader.size() + mBody.size() + mFile.size();
mBytesCurrent = 0;
}