void CInfoCommand::Info (SSRecordPtr pRecord, bool bBasicInfo) { if (bBasicInfo) { std::auto_ptr<SSObject> pObject (new SSObject(pRecord)); GetFormatter()->Format (*pObject); } else { std::auto_ptr<SSObject> pObject (SSObject::MakeObject(pRecord)); GetFormatter()->Format (*pObject); } }
void testSmartPointers() { boost::shared_ptr<int> pInt( new int(2) ); std::cout << "pInt: " << *pInt << std::endl; boost::shared_ptr<Object> pObject( new Object(4) ); boost::shared_ptr<A> pA; boost::shared_ptr<B> pB; { pA.reset( new A() ); pB.reset( new B() ); pA->value = 4; /* A -> B */ pA->b = pB; pB->value = 8; /* B -> A */ //pB->a = pA; } std::cout << "Value of pA: " << pA->value << std::endl; std::cout << "Value of pB: " << pB->value << std::endl; boost::shared_ptr<A> pA2= pB->a.lock(); if(pA2.get() != 0L) { std::cout << "Value of pA: " << pA2->value << std::endl; } std::cout << "Value of pB: " << pA->b->value << std::endl; std::cout << "Refs to pA: " << pA.use_count() << std::endl; std::cout << "Refs to pB: " << pB.use_count() << std::endl; }
static void destroy(CollectableBase* pCollectable) { Ptr<LispObject> pObject(static_cast<LispObject*>(pCollectable)); typeCheck(pObject, Type::Environment); auto& table = pObject->getData<Data>().m_table; table.~HashTable(); }
shared_ptr<FDSObject> GalaxyFDSClient::getObject(const string& bucketName, const string& objectName, long pos, long len) { string uri = formatUri(_pConfig->getDownloadBaseUri(), bucketName + "/" + objectName, vector<string>()); URI pocoUri(uri); shared_ptr<HTTPClientSession> pSession(_pSessionFacotry ->createClientSession(pocoUri)); pSession->setHost(pocoUri.getHost()); pSession->setPort(pocoUri.getPort()); HTTPRequest request(HTTPRequest::HTTP_GET, uri, HTTPMessage::HTTP_1_1); FDSObjectMetadata metadata; if (pos >= 0 || len > 0) { std::ostringstream os; os << "bytes=" << pos << "-"; if (len > 0) { os << (pos + len - 1); // inclusive } metadata.add(Constants::RANGE, os.str()); } prepareRequestHeaders(uri, HTTPRequest::HTTP_GET, "", _emptyStream, metadata, request); HTTPResponse response; pSession->sendRequest(request); istream& rs = pSession->receiveResponse(response); if (response.getStatus() != HTTPResponse::HTTP_OK && response.getStatus() != HTTPResponse::HTTP_PARTIAL_CONTENT) { stringstream msg; msg << "Get object failed, status=" << response.getStatus() << ", reason="; StreamCopier::copyStream(rs, msg); throw GalaxyFDSClientException(response.getStatus(), msg.str()); } shared_ptr<FDSObjectSummary> pObjectSummary(new FDSObjectSummary()); pObjectSummary->setBucketName(bucketName); pObjectSummary->setObjectName(objectName); pObjectSummary->setSize(response.getContentLength()); shared_ptr<FDSObject> pObject(new FDSObject()); pObject->setObjectSummary(pObjectSummary); pObject->setObjectMetadata(this->parseMetadata(response)); pObject->setSession(pSession); pObject->setObjectContent(rs); return pObject; }